#define _CRT_SECURE_NO_WARNINGS #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; #define rep(i, n) for(int i=0; i<(n); i++) #define FOR(i, m, n) for(int i=(m);i<(n);i++) #define sz(x) ((int)(x).size()) #define all(x) (x).begin(),(x).end() #define SORT(x) sort((x).begin(),(x).end()) #define REVE(x) reverse((x).begin(),(x).end()) #define mp make_pair #define pb push_back typedef vector VI; typedef vector VS; typedef vector> VVI; typedef pair PII; typedef long long LL; VI t(1000009, -1); int T(int n) { switch (n) { case 0: case 1: case 2: case 3: return 0; break; case 4: return 1; break; default: if (t[n] != -1)return t[n]; else { int t1 = (T(n - 1) + T(n - 2) + T(n - 3) + T(n - 4)) % 17;; return t[n] = t1; } break; } } int main() { int q; cin >> q; VI n(q); rep(i, q)cin >> n[i]; int max = *max_element(all(n)); VI t(max + 10); rep(i, max+1) { switch (i) { case 0: case 1: case 2: case 3: t[i] = 0; break; case 4: t[i] = 1; break; default: t[i] = (t[i - 1] + t[i - 2] + t[i - 3] + t[i - 4]) % 17; break; } } rep(i, q) { cout << t[n[i]] << endl; } }