mod = (ord('\n') ** ord('\t')) + ord('\a') def mul(a, b): return [ [(a[0][0]*b[0][0] + a[0][1]*b[1][0]) % mod, (a[0][0]*b[0][1] + a[0][1]*b[1][1]) % mod], [(a[1][0]*b[0][0] + a[1][1]*b[1][0]) % mod, (a[1][0]*b[0][1] + a[1][1]*b[1][1]) % mod] ] def pow_matrix(n): res = [[True, False], [False, True]] m = [[True, True], [True, False]] while n: if n & True: res = mul(res, m) m = mul(m, m) n >>= True return res for _ in range(int(input())): n = int(input()) if n == False: print((True + True) % mod) continue mat = pow_matrix(n - True) a = (mat[0][0] * True + mat[0][1] * (True + True)) % mod print(a)