Playing Board Games
Difficulty: Hard

Pingu recently got addicted to board games. Pingu was playing game called Box fitting. He has a $'4\times N'$ board and has lots of boxes of size $'1\times 4'$ and $'4 \times 1'$. He has a large number of boxes of both types(consider infinite for all practical purposes). Now in this game he needs to place the boxes in the such that, the whole board is exactly covered.

He easily was able to complete the game, but he also observed that there can be more than one solution to this game and decided to find out all such solutions. He wants to know how many solutions actually exist so that he can find them all.

Pingu asks you to write a program such that given $N$ you must tell how many solutions exits such that you can fill a  $'4\times N'$ board with  $'1\times 4'$ and $'4\times 1'$ size boxes. Since the answer can be very large print the answer modulo $1000000007$.

**Input Format:**

First line contains T, number of test cases.		
Next T lines each contain one number N.		

**Output Format:**

Print T lines each containing the required answer for the given N.		

**Constraints:**  
$1 \le T \le 10^3$		
$1 \le N \le 10^{18}$


**Sample Input #00**  

    2
	1
	4
	
**Sample Output #00** 

    1
	2
	
**Explanation:**		  
_Sample #00:_		  
In first case, only way to do is use one $'4\times 1'$ box.		
In second case, either use four $'4\times 1'$ boxes or use four $'1\times 4'$ boxes.

Input Format:

Output Format:

Sample Input:

Sample Output:

Python 3 starter code:


Reference solution (C++):
    #include <bits/stdc++.h>
    #define ll long long
    #define matrix(x,n,m) vector<vector<ll> > x(n,vector<ll> (m,0))
    using namespace std;
    ll mod=1000000007;

    void multiply(vector<vector<ll> > &a , vector<vector<ll> > b)
        {
        matrix(temp,4,4);
        for(int i=0;i<4;i++)
            for(int j=0;j<4;j++)
                for(int k=0;k<4;k++)
                    temp[i][j] = (temp[i][j] +(a[i][k]*b[k][j])%mod)%mod;
        a=temp;
    }
    ll solve(ll n)
    {
        if(n<=4)
            return 1 + n/4;
        n-=4;
        matrix(id,4,4);
        for(int i=0;i<4;i++)
            id[i][i]=1;
        matrix(base,4,4);
        base[0][0]=base[0][1]=base[1][2]=base[2][3]=base[3][0]=1;
        while(n)
        {
            if(n&1)
                multiply(id,base);
            multiply(base,base);
            n>>=1;
        }
        return (2*id[0][0] + id[1][0] + id[2][0] + id[3][0])%mod;
    }
    int main()
    {
        ll t,n;
        cin>>t;
        while(t--)
            {
            cin>>n;
            cout<<solve(n)<<endl;
        }
        return 0;
    }