#define _USE_MATH_DEFINES #include "bits/stdc++.h" using namespace std; #define FOR(i,j,k) for(int (i)=(j);(i)<(int)(k);++(i)) #define rep(i,j) FOR(i,0,j) #define each(x,y) for(auto &(x):(y)) #define mp make_pair #define MT make_tuple #define all(x) (x).begin(),(x).end() #define debug(x) cout<<#x<<": "<<(x)< >(b,vector(c,d)) #define vvv(a,b,c,d,e) vector > >(b,vv(a,c,d,e)) using ll = long long; using pii = pair; using vi = vector; using vll = vector; using P = tuple; int L, A[17 * 17 * 17 * 17]; P B(0, 0, 0, 1); int main() { ios::sync_with_stdio(false); cin.tie(0); cout << fixed << setprecision(20); P p = B; for (;; L++) { int a, b, c, d; tie(a, b, c, d) = p; if (B == p && L)break; A[L] = a; int e = (a + b + c + d) % 17; p = tie(b, c, d, e); } int T; cin >> T; rep(i, T) { ll N; cin >> N; N--; N %= L; cout << A[N] << endl; } }