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