#include <bits/stdc++.h>
using namespace std;
long long fac(int n, int mod) {
long long res = 1;
for (int i=1;i<=n;i++) {
res =(res*i)%mod;
}
return res;
}
int qs(int n, int mod) {
if (n % 2 != 0) return 0;
int m1= n / 2;
long long tp = 0;
for (int k = 0; k <= m1; k++) {
int m = m1 - k;
long long num=fac(n, mod);
long long den=(fac(k, mod) * fac(k, mod) % mod) * (fac(m, mod) * fac(m, mod) % mod) % mod;
long long inv = 1;
for (int j = mod - 2; j > 0; j /= 2) {
if (j % 2 != 0) inv = (inv * den) % mod;
den = (den * den) % mod;
}
long long p = (num * inv) % mod;
tp = (tp + p) % mod;
}
return tp;
}
int main() {
freopen("diary.in","r",stdin);
freopen("diary.out","w",stdout);
int mod=1997,n,t;
cin>>t;
while(t--){
cin>>n;
cout <<qs(n, mod)<<endl;
}
return 0;
}