n = int(input()) dp = [0] * (pow(10, 6)) dp[0] = 0 dp[1] = 0 dp[2] = 0 dp[3] = 1 for i in range(4, pow(10, 6)): dp[i] = (dp[i-1] + dp[i-2] + dp[i-3] + dp[i-4]) % 17 for i in range(n): j = int(input()) print(dp[j-1])