Q_num = int(input()) query = [ int(input()) for _ in range(Q_num) ] q_max = max(query) Ti = [0] * 1000000 Ti[3] = 1 for i in range(4, q_max): Ti[i] = Ti[i-4] + Ti[i-3] + Ti[i-2] + Ti[i-1] for n in query: print(Ti[n-1]%17)