#P15910. [TOPC 2024] Fibonacci Lucky Numbers

    ID: 15833 远端评测题 2000ms 512MiB 尝试: 0 已通过: 0 难度: 7 上传者: 标签>2024矩阵加速ICPC台湾欧拉降幂

[TOPC 2024] Fibonacci Lucky Numbers

Description

Welcome to the Lucky 777 Slot Game! This game is known for its complex mathematical challenges, where only the smartest can win the jackpot.

The slot machine is powered by a mysterious sequence—the Fibonacci sequence. But it’s no ordinary Fibonacci sequence; it has a twist inspired by the number 77, the symbol of luck in slot games.

When you pull the lever of the Lucky 777 Slot Machine, it generates a gigantic number using an integer nn and the power of sevens: 77n7^{7^n}. This number, however, is so massive that even the most powerful computers cannot handle it directly.

To claim the jackpot, you need to compute the last 1010 digits of the F77nF_{7^{7^n}}, the 77n7^{7^n}-th Fibonacci number.

Note

The Fibonacci sequence is defined as:

  • F0=0F_0 = 0
  • F1=1F_1 = 1
  • Fk=Fk1+Fk2F_k = F_{k-1} + F_{k-2} for k2k \ge 2

Input Format

The first line contains an integer tt indicating the number of test cases. Each of the following tt lines is a test case and contains exactly one positive integer nn.

Output Format

For each test case, output one line containing the last 1010 digits of F77nF_{7^{7^n}}.

5
1
2
3
4
5
1353646637
3172443437
2364206637
9010523437
9481646637

Hint

  • 1t201 \le t \le 20
  • 1n1091 \le n \le 10^9