#include using namespace std; vector Tetra(int n) { vector T(4917, 0); T[4] = 1; for (size_t i = 5; i < 4917; i++) { T[i] = (T[i - 1] + T[i - 2] + T[i - 3] + T[i - 4]) % 17; } return T; } int main() { vector T = Tetra(4917); long long n; cin >> n; while (cin >> n) { n -= (n - 4) / 4912 * 4912; cout << T[n] << endl; } }