#T341. Pell数列

Pell数列

Description

The Pell sequence a_1,a_2,a_3,a\_1, a\_2, a\_3, \dots is defined as follows: a_1=1a\_1 = 1, a_2=2a\_2 = 2, \dots, a_n=2a_n1+a_n2a\_n = 2 a\_{n−1} + a\_{n-2} (for n>2n > 2). Given a positive integer kk, find the value of the kk-th term in the Pell sequence modulo 3276732767.

Input Format

The first line contains the number of test cases nn, followed by nn lines of input. Each test case occupies one line and consists of a positive integer kk (1k<10000001 \leq k < 1000000).

Output Format

Output nn lines, each corresponding to an input. Each output should be a non-negative integer.

2
1
8

1
408