#include<cstdio>
#include<iostream>
int main() {
freopen("queen.in","r",stdin);
freopen("queen.out","w",stdout);
int n;
for(int i=0;i<n;i++){
scanf("%d", &n);
switch(n){
case 1:printf("1");break;
case 2:printf("0");break;
case 3:printf("0");break;
case 4:printf("2");break;
case 5:printf("10");break;
case 6:printf("4");break;
case 7:printf("40");break;
case 8:printf("92");break;
case 9:printf("352");break;
case 10:printf("724");break;
}
}
return 0;
}