#t328. Pell 数列
Pell 数列
Pell Sequence
Problem Background
Special for beginners, ^_^
Problem Description
The Pell sequence is defined as follows: $a_1 = 1, a_2 = 2, \dots, a_n = 2a_{n-1} + a_{n-2} \; (n > 2)$.
Given a positive integer , find the value of the -th term of the Pell sequence modulo .
Input Format
The first line is the number of test cases , followed by lines of input. Each test case occupies one line and contains a positive integer .
Output Format
lines, each line outputs the result corresponding to one input. The output should be a non-negative integer.
Sample Input
2
1
8
Sample Output
1
408
Constraints
Time limit: 1s, memory limit: 1024KiB for each test case.