Excellent Numbers 2

Time limit: 0.2s Memory limit: 64MB Input: Output:

Task

A positive integer is called excellent if its decimal representation contains only the digits 11 and 55, and it is divisible by 33.
For example, 1515 and 111111 are excellent numbers (15=53+015 = 5 \cdot 3 + 0 and 111=373+0111=37\cdot 3 + 0), while 151151 is not (151=503+1151 = 50\cdot 3 + 1).

Alex observed that there are many excellent numbers formed by NN digits, and thus he started counting them. However, this is taking too much time, so he gave this task as a homework for you: help him count how many excellent numbers of NN digits exist!

Since the answer can be big, print it modulo 109+710^9 + 7.

Input data

The first line of the input file contains a single integer TT, the number of test cases. TT test cases follow, each preceded by an empty line.

Each test case consists of: a line containing 64-bit integer NN, representing the number of digits for which we have to find the answer.

Output data

The output file must contain TT lines corresponding to the test cases, each consisting of integer ansans, representing the number of excellent numbers with NiN_i digits modulo 109+710^9 + 7 (i.e. the reminder of the division by 109+710^9 + 7).

Constraints and clarifications

  • 1T101 \le T \le 10.
  • 1N10181 \le N \le 10^{18}.
# Points Constraints
1 0 Examples
2 13 N20N \le 20
3 24 N2 000N \le 2\ 000
4 34 N200 000N \le 200\ 000
5 29 No additional constraints

Example

stdin

5
5
3
10
39
952

stdout

10
2
342
251936681
897205658

Explanation

In the first testcase of the sample case, we have N=5N=5.
There are 1010 excellent numbers with 55 digits.
In increasing order they are: 1111511115, 1115111151, 1151111511, 1511115111, 1555515555, 5111151111, 5155551555, 5515555155, 5551555515 and 5555155551.

In the second testcase we have N=3N=3.
There are 22 excellent numbers with 33 digits: 111111 and 555555.

In the fourth testcase there are 183251937962183\,251\,937\,962 excellent numbers with N=39N=39 digits.
This number modulo 109+710^9+7 is 251936681251\,936\,681.

Log in or sign up to be able to send submissions!