#Fibonacchi sequence import numpy as np A = np.array([[1, 1, 1, 1], [1, 0, 0, 0], [ 0, 1, 0, 0], [0, 0, 1, 0]], dtype="int64") mod = 17 def mat_f(X): if X == 0: return np.array([[1, 0, 0, 0], [0, 1, 0, 0], [0, 0, 1, 0], [0, 0, 0, 1]]) elif X == 1: return A else: if X % 2 == 0: S = mat_f(X//2) S %= mod return np.dot(S, S) else: S = mat_f(X//2) S %= mod return np.dot(np.dot(S, S), A) Q = int(input()) d = [int(input()) for i in range(Q)] for i in range(Q): K=np.dot(mat_f(d[i]-1),np.array([1,0,0,0])) ans=(K[-1])%mod print(ans)