#include #include #include using namespace std; int main(){ int Q; cin >> Q; int n[Q]; for (int i = 0; i < Q; i++){ cin >> n[i]; } vector tetranatti = {0, 0, 0, 1}; for (int i = 4; true; i++){ if (tetranatti[i - 1] == 1 && tetranatti[i - 2] == 0 && tetranatti[i - 3] == 0 && tetranatti[i - 4] == 0 && i != 4){ tetranatti.pop_back(); tetranatti.pop_back(); tetranatti.pop_back(); tetranatti.pop_back(); break; }else{ tetranatti.push_back((tetranatti[i - 1] + tetranatti[i - 2] + tetranatti[i - 3] + tetranatti[i - 4]) % 17); } } for (int i = 0; i < Q; i++){ cout << tetranatti[(n[i] - 1) % tetranatti.size()] << endl; } }