#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <algorithm>
#include <set>
#include <map>
#include <bitset>
#include <cmath>
#include <functional>
#include <iomanip>
#define vll vector<ll>
#define vvvl vector<vvl>
#define vvl vector<vector<ll>>
#define VV(a, b, c, d) vector<vector<d> >(a, vector<d>(b, c))
#define VVV(a, b, c, d) vector<vvl>(a, vvl(b, vll (c, d)));
#define re(c, b) for(ll c=0;c<b;c++)
#define all(obj) (obj).begin(), (obj).end()
typedef long long int ll;
typedef long double ld;
using namespace std;

#define P 1000000007
#define N_MAX 10000000
typedef long long int ll;
ll fac[N_MAX+1];
ll inv[N_MAX+1];
ll finv[N_MAX+1];

ll comb(ll n, ll k){
  if(n<0||k<0||n<k) return 0;
  return (((fac[n]*finv[n-k])%P)*finv[k])%P;
}
ll perm(ll n, ll k){
  if(n<0||k<0||n<k) return 0;
  return (fac[n]*finv[n-k])%P;
}

void init(){
  fac[0] = finv[0] = fac[1] = finv[1] = inv[1] = 1;
  for(int i = 2; i <= N_MAX; i++){
    fac[i] = (fac[i-1]*i)%P;
    inv[i] = ((-(P/i)*inv[P%i])%P+P)%P;
    finv[i] = (finv[i-1]*inv[i])%P;
  }
}
ll pp(ll a, ll b){
  return (a * b)%P;
}


// matrix<集合> (集合, 加法における単位元, 加算, 乗算)
template<typename T>
struct matrix{
  function<T(T, T)> f, g;
  vector<vector<T>> mat;
  T unit;

  matrix(vector<vector<T>> v, T UNIT, function<T(T, T)> add_func,
  function<T(T, T)> multi_func):f(add_func), g(multi_func), unit(UNIT){
    mat = v;
  }

  matrix<T> t(){
    vector<vector<T>> ret(mat[0].size(), vector<T>(mat.size()));
    re(i, mat[0].size()) re(j, mat.size()) ret[i][j] = mat[j][i];
    return matrix<T>(ret, f, g);
  }

  matrix<T> operator * (matrix<T> B){
    vector<vector<T>> ret(mat.size(), vector<T>(B.mat[0].size(), unit));
    if(mat[0].size()!=B.mat.size()){
      std::cout << "matrix operator " << "*" << " error" << '\n';
      return matrix<T>(ret, unit, f, g);
    }
    re(i, mat.size()){
      re(j, B.mat[0].size()){
        re(k, mat[0].size()){
          ret[i][j] = f(ret[i][j], g(mat[i][k], B.mat[k][j]));
        }
      }
    }
    return matrix<T>(ret, unit, f, g);
  }

  matrix<T> operator * (ll num){
    vector<vector<T>> ret = mat;
    re(i, mat.size()) re(j, mat[0].size()) ret[i][j] *= num;
    return matrix<T>(ret, unit, f, g);
  }

  matrix<T> operator + (matrix<T> B){
    vector<vector<T>> ret = mat;
    if(mat.size()!=B.mat.size()||mat[0].size()!=B.mat[0].size()){
      std::cout << "matrix operator " << "+" << " error" << '\n';
      return matrix<T>(ret, unit, f, g);
    }
    re(i, mat.size()) re(j, mat[0].size()) ret[i][j] = f(mat[i][j], B.mat[i][j]);
    return matrix<T>(ret, unit, f, g);
  }

  matrix<T> operator ^ (ll num){
    matrix<T> ret(vector<vector<T>> (0, vector<T>(0)), unit, f, g);
    if(mat.size()!=mat[0].size()){
      std::cout << "matrix operator " << "^" << " error" << '\n';
      return ret;
    }
    matrix<T> tmp(mat, unit, f, g);
    bool flag = false;
    while(num>0){
      if(num%2){
        if(flag) ret = ret * tmp;
        else ret.mat = tmp.mat, flag = true;
      }
      num/=2, tmp = tmp * tmp;
    }
    return ret;
  }
  vector<T> & operator [](int n){
    return mat[n];
  }
};

ll ad(ll a, ll b){return (a+b)%P;}
ll ml(ll a, ll b){return (a*b)%P;}

matrix<ll> d(VV(21, 21, 0, ll), 0LL, ad, ml);
matrix<ll> a(VV(21, 1, 0, ll), 0LL, ad, ml);

void matinit(){
  a[0][0] = 1;
  // row 0 ~ 9 = 偶数or奇数
  // row 10 ~ 19 自由
  // row 20 終わり

  /*
  0個偶数 -> 0個奇数, 1個奇数, 2個奇数, 3個奇数, 4個奇数, 自由1
  0個奇数 -> 0個偶数
  自由1 -> 自由1, 自由2
  自由10が答え
  */
  //偶奇の遷移
  for(int i=0;i<5;i++){
    for(int j=i;j<5;j++){
      //偶数から奇数
      d[j*2+1][i*2] = 1;
    }
    //偶数から終わり
    d[20][i*2] = 1;
    //自由枠1~10へ
    for(int j=0;j<10;j++) d[10 + j][i*2] = 1;

    //奇数から偶数
    d[i*2][i*2+1] = 1;
  }
  d[20][20] = 1;

  //自由枠の遷移
  for(int i=10;i<20;i++) for(int j=i;j<=20;j++) d[j][i] = 1;
}

void solve(){
  ll n;std::cin >> n;

  if(n<=5) {
    std::cout << (n==5?1:0) << '\n';
    return;
  }

  matrix<ll> ans = (d ^ (n-5)) * a;
  ll ret = 0;
  for(int i=0;i<5;i++) ret = (ret + ans[i*2][0])%P;
  for(int i=10;i<=20;i++) ret = (ret + ans[i][0])%P;
  std::cout << ret << '\n';
}

int main(int argc, char const *argv[]) {
  init();
  matinit();

  ll T;std::cin >> T;
  re(t, T) solve();
  return 0;
}


Measured memory_bytes: 237552