Server Time: Wed Feb 26, 2020 12:38 pm
Welcome ( logout
D - Tiles
PDF (English) Ranklist
Time Limit: 2 second(s) Memory Limit: 32 MB

There is a huge 2 x N board, six types of tiles are available, and each of them is infinitely many, you have to find the number of ways you can fill the board using the tiles. Two board configurations are different if at least in one cell, their colors differ. The tiles are given below:

a1.png    a2.png    a3.png    a4.png    a5.png    a6.png

You cannot rotate or flip any tile. And no cell in the board should be empty. The tiles shouldn't overlap.

For example, a 2 x 3 board can be colored by 5 ways, they are:

b1.png    b2.png    b3.png    b4.png    b5.png

Input

Input starts with an integer T (≤ 10000), denoting the number of test cases.

Each case starts with a line containing an integer N (1 ≤ N ≤ 109).

Output

For each case, print the case number and the number of ways the board can be colored. The number may be large, so, output the number modulo 10007.

Sample Input

Output for Sample Input

5

3

10

20

100

87

Case 1: 5

Case 2: 1255

Case 3: 6239

Case 4: 6542

Case 5: 5502

 


Problem Setter: Jane Alam Jan
Developed and Maintained by
JANE ALAM JAN
Copyright © 2012
LightOJ, Jane Alam Jan