tetranacci = {1: 0, 2: 0, 3: 0, 4: 1} def t(n: int): a, b, c, d = tetranacci[4], tetranacci[3], tetranacci[2], tetranacci[1] for i in range(5, n + 1): a, b, c, d = (a + b + c + d) % 17, a, b, c tetranacci[i] = a Q = int(input()) xs = [int(input()) for _ in range(Q)] t(max(xs)) for x in xs: print(tetranacci[x])