#Fibonacchi sequence import numpy as np import sys input = sys.stdin.readline A=np.array([[1, 1, 1, 1], [1, 0, 0, 0], [ 0, 1, 0, 0], [0, 0, 1, 0]]) 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) return np.dot(S, S) % mod else: S = mat_f(X//2) return np.dot(np.dot(S, S), A) % mod def main(): 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) if __name__ == "__main__": main()