Q = int(input()) lsT = [0,0,0,0,1] for i in range(5,10**6+1): lsT.append((lsT[i-1]+lsT[i-2]+lsT[i-3]+lsT[i-4])%17) for i in range(Q): n = int(input()) print(lsT[n])