Q = int(input()) N = 10 T = [0] * (N + 1) T[4] = 1 tmp = sum(T[1:5]) for i in range(5, N+1): T[i] = tmp tmp += T[i] - T[i-4] tmp %= 17 for _ in range(Q): print(T[int(input())])