This page is still under construction.

Parts of this page are still being built. What you see may change.

Fibonacci Sequence

Time limit2sMemory limit512 MB

Summary
For up to 1000 queries, compute the x-th Fibonacci number modulo 10^9, where x can be as large as 2^48.
Level

Medium7 of 10

Topics
Math, Matrix, Divide and conquer, Number theory
Solved
No attempts yet

Problem

Read an integer xx and compute f(x)f(x) modulo 10910^9, where f(x)f(x) is the xx-th value of the Fibonacci sequence.

The Fibonacci sequence is defined as follows.

f(1)=f(2)=1f(1) = f(2) = 1

f(k)=f(k−1)+f(k−2)(k>2)f(k) = f(k-1) + f(k-2) \quad (k > 2)

Input

The first line contains the number of test cases tt (1≤t≤10001 \le t \le 1000).

Each of the next tt lines contains one integer xx (1≤x≤2481 \le x \le 2^{48}).

Output

For each test case, print f(x)f(x) modulo 10910^9 on its own line.

Examples3

  1. Example 1

    Input
    11
    1
    2
    8
    20
    46
    60
    3749999998
    3749999999
    3750000000
    3750000001
    281474976710656
    
    Expected output
    1
    1
    21
    6765
    836311903
    8755920
    499999999
    500000001
    0
    500000001
    309764667
    
  2. Example 2

    Input
    1
    1
    
    Expected output
    1
  3. Example 3

    Input
    20
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    
    Expected output
    1
    1
    2
    3
    5
    8
    13
    21
    34
    55
    89
    144
    233
    377
    610
    987
    1597
    2584
    4181
    6765