#include<cstdio> #include<cstring> #include<iostream> #include<algorithm> #define LL long long using namespace std; typedef __int64 int64; const int N = 3; __int64 k , MOD = 1e9+7; int arr[50] ; struct Matrix{ int64 mat[N][N]; Matrix operator*(const Matrix& m)const{ Matrix tmp; for(int i = 0 ; i < N ; i++){ for(int j = 0 ; j < N ; j++){ tmp.mat[i][j] = 0; for(int k = 0 ; k < N ; k++){ tmp.mat[i][j] += mat[i][k]*m.mat[k][j]%MOD; tmp.mat[i][j] %= MOD; } } } return tmp; } }; int64 Pow(Matrix &m , __int64 k){ Matrix ans; memset(ans.mat , 0 , sizeof(ans.mat)); for(int i = 0 ; i < N ; i++) ans.mat[i][i] = 1; while(k){ if(k&1) ans = ans*m; k >>= 1; m = m*m; } int64 sum = 0; for(int i = 0 ; i < N ; i++){ for(int j = 0; j < N; j++){ sum += ans.mat[i][j]*arr[j+1]%MOD; sum %= MOD; } } return sum; } void init(Matrix &m){ memset(m.mat , 0 , sizeof(m.mat)); m.mat[0][0] = 1; m.mat[0][2] = 1; m.mat[1][0] = 1; m.mat[2][1] = 1; } int main(){ Matrix m; arr[1] = 1; arr[2] = 1; arr[3] = 1; int t; scanf("%d",&t); while(t--){ scanf("%I64d",&k); init(m); if(k == 2) printf("2 "); else printf("%I64d " , Pow(m , k-2));//输入n时计算矩阵的m次方,则Pow(n-(n-m)) } return 0; }