import sys sys.setrecursionlimit(100000000) MOD = 17 INF = 10 ** 15 from bisect import bisect_left,bisect_right def main(): Q = int(input()) Ns = [int(input()) for _ in range(Q)] tetora = [0] * 1000001 tetora[4] = 1 for i in range(5,1000001): tetora[i] = tetora[i - 1] + tetora[i - 2] + tetora[i - 3] + tetora[i - 4] tetora[i] %= MOD print(*[tetora[q] for q in Ns],sep = '\n') if __name__ == '__main__': main()