import numpy as np MOD = 17 def matmul(A, B): return (A @ B) % MOD I = np.identity(4, dtype=np.int64) def power_matrix(A, n): result = I.copy() while n: if n & 1: result = matmul(result, A) A = matmul(A, A) n >>= 1 return result A = np.array([ [0, 1, 0, 0], [0, 0, 1, 0], [0, 0, 0, 1], [1, 1, 1, 1], ], dtype=np.int64) Q = int(input()) for _ in range(Q): n = int(input()) print(power_matrix(A, n)[0, 0])