import sys input = sys.stdin.buffer.readline def main(): Q = int(input()) q = [0]*Q for i in range(Q): q[i] = int(input()) n = 10**6+1 T = [0]*n T[0] = 0 T[1] = 0 T[2] = 0 T[3] = 1 for i in range(4, n): T[i] = T[i-4]+T[i-3]+T[i-2]+T[i-1] T[i] %= 17 #print(T[0:10]) for i in range(Q): print(T[q[i]-1]) if __name__ == '__main__': main()