def main(): q = int(input()) t = [0] * 1001000 t[3] = 1 for i in range(4, 1000500): t[i] = (t[i - 1] + t[i - 2] + t[i - 3] + t[i - 4]) % 17 for i in range(q): n = int(input()) print(t[n-1]) if __name__ == '__main__': main()