import sys read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline readlines = sys.stdin.buffer.readlines Q,*N = map(int,read().split()) U = 17 ** 4 + 10 T = [0] * U T[0] = 1 for n in range(4,U): T[n] = sum(T[n-4:n]) % 17 P = 17 ** 4 - 17 for n in N: print(T[n%P])