cash = {1: 0, 2: 0, 3: 0, 4: 1} def t(n: int) -> int: if n in cash: return cash[n] a, b, c, d = 1, 0, 0, 0 # n-1, ..., n-4 for i in range(5, n + 1): a, b, c, d = (a + b + c + d) % 17, a, b, c cash[i] = a return a Q = int(input()) for _ in range(Q): nq = int(input()) print(t(nq))