def tetra(qs): seed = [0, 0, 0, 1] for step in range(0, 4): if step + 1 in qs: yield seed[step] for step in range(5, max(qs) + 1): seed.append(sum(seed) % 17) seed = seed[1:] if step in qs: yield seed[-1] nq = int(input()) qs = [int(input()) for _ in range(nq)] for t in tetra(qs): print(t)