#include using namespace std; typedef long long ll; #define rep(i, n) for (int i = 0; i < (int)(n); i++) #define req(i,n) for(int i = 1;i <= n; i++) #define rrep(i,n) for(ll i = n-1;i >= 0;i--) #define ALL(obj) begin(obj), end(obj) #define RALL(a) rbegin(a),rend(a) typedef long long int ll; typedef long double ld; const int MAX = 510000; const ll MOD = 1000000007; template inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; } template inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; } int main(void) { int n;cin >>n; vector dp(20000,0); dp[0] = 0;dp[1]=0;dp[2]=0;dp[3]=1; rep(i,10000) dp[i+4]=(dp[i]+dp[i+1]+dp[i+2]+dp[i+3])%17; rep(i,n){ ll q;cin >>q;q%=4912;q--; cout << dp[q] <