luogu#P4838. P哥破解密码

P哥破解密码

Background

Brother P is a boy who often loses his password slips.

At the ION8102 contest site, Brother P lost his password slip again. As someone who can get full marks on the written test, he of course knows that this will cost him 55 points as a penalty, so he started cracking the password of the IONXunil system.

Problem Description

Define a string as valid if and only if it is made up only of A\verb!A! and B\verb!B!, and it does not contain 33 consecutive A\verb!A! characters. Brother P knows that the password is the number of valid strings of length NN, taken modulo 1926081719260817. But Brother P cannot compute it, so he can only tell you NN and ask you to compute it.

As for why the result is taken modulo this number, it seems to be in memory of someone, but who exactly that is, Brother P does not remember either.

However, he forgot what the string length NN should be, so he plans to try MM sets of testdata.

Input Format

The first line gives an integer MM, which represents the number of queries.

Then follow MM lines, each giving a positive integer NN, meaning the length of the string in that query.

Output Format

For each query, output one integer per line, representing the answer.

3
1
3
6

2
7
44

Hint

Explanation of the samples.

When the length is 11, there are only two arrangements: A\verb!A! and B\verb!B!, and both are valid.

When the length is 33, all strings are valid except AAA\verb!AAA!, so there are 2312^3-1 strings.

Constraints.

  • For 20%20\% of the testdata, all N20N\leq20, M2M\leq2.
  • For 70%70\% of the testdata, all N107N\leq10^7.
  • For 100%100\% of the testdata, all N109N\leq10^9, M10M\leq10.

Translated by ChatGPT 5