Panda has received an assignment of painting a line of blocks. Since Panda is such an intelligent boy, he starts to think of a math problem of painting. Suppose there are N blocks in a line and each block can be paint red, blue, green or yellow. For some myterious reasons, Panda want both the number of red blocks and green blocks to be even numbers. Under such conditions, Panda wants to know the number of different ways to paint these blocks.
The first line of the input contains an integer T(1≤T≤100), the number of test cases. Each of the next T lines contains an integer N(1≤N≤10^9) indicating the number of blocks.
For each test cases, output the number of ways to paint the blocks in a single line. Since the answer may be quite large, you have to module it by 10007.
2 1 2Sample Output
2 6
//#include<bits/stdc++.h>
#include<iostream>
#include<vector>
using namespace std;
int mod=10007;
#define f(i,n) for(i=0;i<n;i++)
typedef vector<int> vec;
typedef vector<vec> mat;
mat mul(mat &a,mat &b){
mat c(3,vec(3));
int i,j,k;
f(i,3)
f(k,3)
f(j,3)
c[i][j]=(c[i][j]+a[i][k]*b[k][j])%mod;
return c;
}
typedef long long ll;
mat pow(mat a,ll n){
mat b(3,vec(3));
int i;
f(i,3)b[i][i]=1;
while(n>0){
if(n&1)b=mul(b,a);
a=mul(a,a);
n/=2;
}
return b;
}
int main(){
//freopen("in.txt","r",stdin);
int n;
int t;
cin>>t;
while(t--){
cin>>n;
mat a(3,vec(3));
a[0][0]=2;a[0][1]=1;a[0][2]=0;
a[1][0]=2;a[1][1]=2;a[1][2]=2;
a[2][0]=0;a[2][1]=1;a[2][2]=2;
a=pow(a,n);
printf("%d\n",a[0][0]);
}
// fclose(stdin);
}