#!/usr/bin/env python def Tn(n): global tlist ans = sum(tlist[n-4:n]) % 17 return ans Q = int(input()) inval = [] for i in range(Q): inval.append(int(input())) tlist = [0, 0, 0, 0, 1, 1] k = float('inf') for i in range(6,max(inval)+1): res = sum(tlist[i-4:i])%17 tlist.append(res) if tlist[-4:] == [0, 0, 0, 1]: k = i break for n in inval: if n <= k: print(tlist[n]) else: print(tlist[(n-1)%(k-4)+1])