T = { 1: 0, 2: 0, 3: 0, 4: 1 } def tetra(i): if i in T: return T[i] else: t = (tetra(i - 1) % 17 + tetra(i - 2) % 17 + tetra(i - 3) % 17 + tetra(i - 4) % 17) % 17 T[i] = t return t for i in range(5, 4917): tetra(i) Q = int(input()) for _ in range(Q): print(T[(int(input()) - 1) % 4912 + 1])