#include #include #include #include #include #include #include #include #include int main(void) { std::vector t = { 0, 0, 0, 1 }; bool matched = false; int i = 4; while (!matched) { t.push_back((t[i - 1] + t[i - 2] + t[i - 3] + t[i - 4]) % 17); if (t[i] == 1 && t[i - 1] == 0 && t[i - 2] == 0 && t[i - 3] == 0) { matched = true; } i = i + 1; } long long mod = i - 4; int n; long long a; std::cin >> n; for (i = 0; i < n; i++) { std::cin >> a; a--; a %= mod; std::cout << t[a] << std::endl; } return 0; }