#include <bits/stdc++.h>
#define ll long long
using namespace std;
const int con = 2e3+10;
const int mod = 1997;
int n;
int c[con][con];
int N;
int T;
void init(){
n=2000;
for (int i = 0; i <= n; i++){
for (int j = 0; j <= i; j++){
if(j==0){
c[i][j]=1;
}
else{
c[i][j]=(c[i-1][j]+c[i-1][j-1])%mod;
}
}
}
}
int main(){
freopen("diary.in","r",stdin);
freopen("diary.out","w",stdout);
init();
scanf("%d",&T);
while(T--){
scanf("%d",&N);
if(N%2){
printf("0\n");
continue;
}
int res=0;
for(int dong=0;dong<=N/2;dong++){
int xi=N/2-dong;
int bei=N/2-dong;
int nan=N/2-bei;
int v=c[N][dong];
(v*=c[N-dong][xi])%=mod;
(v*=c[N-dong-xi][nan])%=mod;
(v*=c[N-dong-xi-nan][bei])%=mod;
(res+=v)%=mod;
}
printf("%d\n",res);
}
return 0;
}