#include using namespace std; using ll = long long; using ul = unsigned long; int main() { ios::sync_with_stdio(false); cin.tie(nullptr); int q; cin >> q; vector vn(q); for (auto&& n : vn) cin >> n; auto it = max_element(vn.begin(), vn.end()); long maxq = *it; vector t(maxq + 1, 0); if (maxq > 4) { t[1] = 0; t[2] = 0; t[3] = 0; t[4] = 1; for (long i = 5; i <= maxq; ++i) t[i] = (t[i - 1] + t[i - 2] + t[i - 3] + t[i - 4]) % 17; } else if (maxq == 4) t[4] = 1; for (const auto& n : vn) cout << t[n] << "\n"; return 0; }