# -*- coding: utf-8 -*- """ No.657 テトラナッチ数列 Easy https://yukicoder.me/problems/no/657 """ import sys from sys import stdin from collections import deque input = stdin.readline def solve(limit): res = [0] * (limit+1) res[4] = 1 tetra = deque([0, 0, 0, 1]) for i in range(5, limit+1): tmp = sum(tetra) % 17 res[i] = tmp tetra.append(tmp) tetra.popleft() return res def main(args): Q = int(input()) queries = [int(input()) for _ in range(Q)] tetra = solve(max(queries)) for q in queries: print(tetra[q]) if __name__ == '__main__': main(sys.argv[1:])