def main(): Q = int(input()) dp = [0] * (10 ** 6 + 5) dp[1] = 0 dp[2] = 0 dp[3] = 0 dp[4] = 1 for i in range(5, 10 ** 6 + 2): dp[i] = dp[i-1] + dp[i-2] + dp[i-3] + dp[i-4] dp[i] %= 17 for _ in range(Q): n = int(input()) print(dp[n]) if __name__ == "__main__": main()