Under construction

Still being built. Things may change

Fibonacci Lucky Numbers

Time limit2sMemory limit1024 MB

Summary
Given n, output the last 10 digits of the Fibonacci number whose index is 7 raised to 7 raised to 7^n, for up to 20 test cases.
Level

Medium7 of 10

Topics
Number theory, Math, Matrix
Solved
No attempts yet

Problem

Welcome to the Lucky 777 Slot Game! This game is known for its complex math problems, and only the smartest players win the jackpot.

The slot machine runs on a mysterious sequence, the Fibonacci sequence. It is not the ordinary version, though. The twist is based on the number 77, the symbol of luck in slot games.

When you pull the lever on the Lucky 777 Slot Machine, it generates a huge number from an integer nn and a power of sevens: 777n7^{7^{7^n}}. This number is too large for even the most powerful computers to handle directly.

To claim the jackpot, you must compute the last 1010 digits of F777nF_{7^{7^{7^n}}}, the 777n7^{7^{7^n}}-th Fibonacci number.

Input

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

Output

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

Constraints

  • 1≤t≤201 ≤ t ≤ 20
  • 1≤n≤1091 ≤ n ≤ 10^9

Hint

The Fibonacci sequence is defined as:

  • F0=0F_0 = 0
  • F1=1F_1 = 1
  • Fk=Fk−1+Fk−2F_k = F_{k-1} + F_{k-2} for k≥2k ≥ 2

Examples1

  1. Example 1

    Input
    5
    1
    2
    3
    4
    5
    
    Expected output
    1353646637
    3172443437
    2364206637
    9010523437
    9481646637