#include using namespace std; int T[1000001] = {0, 0, 0, 1}; int main() { int Q, n; for (int i = 4; i <= 1000000; i++) T[i] = T[i - 1] + T[i - 2] + T[i - 3] + T[i - 4]; cin >> Q; for (int i = 0; i < Q; i++) { cin >> n; cout << T[n - 1] % 17 << endl; } return 0; }