#include #include using namespace std; using ll=long long; #define rep(i,n) for(int i=0;i=0;i--) #define all(v) v.begin(),v.end() #define rall(v) v.rbegin(),v.rend() template bool chmax(T &a, T b){if (a < b){a = b;return true;} else return false;} template bool chmin(T &a, T b){if (a > b){a = b;return true;} else return false;} const int MOD=17; template vector> pd(vector> &A, vector> &B){ int nx = A.size(), mx = A[0].size(), lx = B[0].size(); vector> C(nx, vector(lx)); for (int i = 0; i < nx; i++){ for (int j = 0; j < lx; j++){ for (int k = 0; k < mx; k++){ C[i][j] += A[i][k] * B[k][j]; C[i][j] %= MOD; } } } return C; } template vector>> set_matrix(vector> A){ vector>> V; for (int i = 0; i < 60; i++){ V.push_back(A); A = pd(A, A); } return V; } template vector> matrix_pow(vector>> &V, ll k){ int l = V[0].size(); vector> M(l ,vector(l)); for (int i = 0; i < l; i++){ M[i][i] = 1; } for (int i = 0; i < 60; i++){ if (k >> i & 1){ M = pd(V[i], M); } } return M; } int main(){ ios::sync_with_stdio(false); cin.tie(nullptr); int q; cin>>q; vector>A={{1,1,1,1},{1,0,0,0},{0,1,0,0},{0,0,1,0}}; vector>>V=set_matrix(A); while(q--){ ll n; cin>>n; n-=4; vector>M=matrix_pow(V,n); if(n<0)cout<<0<<"\n"; else cout<