#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, x, n) for(int i = x; i <= n; i++)
#define rep3(i, x, n) for(int i = x; i >= n; i--)
#define elif else if
#define sp(x) fixed << setprecision(x)
#define pb push_back
#define eb emplace_back
#define all(x) x.begin(), x.end()
#define sz(x) (int)x.size()
using ll = long long;
using pii = pair<int, int>;
using pil = pair<int, ll>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
const int MOD = 1000000007;
//const int MOD = 998244353;
const int inf = (1<<30)-1;
const ll INF = (1LL<<60)-1;
const double pi = acos(-1.0);
const double EPS = 1e-10;
template<typename T> bool chmax(T &x, const T &y) {return (x < y)? (x = y, true) : false;};
template<typename T> bool chmin(T &x, const T &y) {return (x > y)? (x = y, true) : false;};

template<int mod>
struct Mod_Int{
    ll x;

    Mod_Int() : x(0) {}

    Mod_Int(ll y) : x(y >= 0 ? y % mod : (mod - (-y) % mod) % mod) {}

    Mod_Int &operator += (const Mod_Int &p){
        x = (x + p.x) % mod;
        return *this;
    }

    Mod_Int &operator -= (const Mod_Int &p){
        x = (x + mod - p.x) % mod;
        return *this;
    }

    Mod_Int &operator *= (const Mod_Int &p){
        x = (x * p.x) % mod;
        return *this;
    }

    Mod_Int &operator /= (const Mod_Int &p){
        *this *= p.inverse();
        return *this;
    }

    Mod_Int &operator ++ () {return *this += Mod_Int(1);}

    Mod_Int operator ++ (int){
        Mod_Int tmp = *this;
        ++*this;
        return tmp;
    }

    Mod_Int &operator -- () {return *this -= Mod_Int(1);}

    Mod_Int operator -- (int){
        Mod_Int tmp = *this;
        --*this;
        return tmp;
    }

    Mod_Int operator - () const {return Mod_Int(-x);}

    Mod_Int operator + (const Mod_Int &p) const {return Mod_Int(*this) += p;}

    Mod_Int operator - (const Mod_Int &p) const {return Mod_Int(*this) -= p;}

    Mod_Int operator * (const Mod_Int &p) const {return Mod_Int(*this) *= p;}

    Mod_Int operator / (const Mod_Int &p) const {return Mod_Int(*this) /= p;}

    bool operator == (const Mod_Int &p) const {return x == p.x;}

    bool operator != (const Mod_Int &p) const {return x != p.x;}

    Mod_Int inverse() const {
        assert(*this != Mod_Int(0));
        return pow(mod-2);
    }

    Mod_Int pow(ll k) const{
        Mod_Int now = *this, ret = 1;
        while(k){
            if(k&1) ret *= now;
            now *= now, k >>= 1;
        }
        return ret;
    }

    friend ostream &operator << (ostream &os, const Mod_Int &p){
        return os << p.x;
    }

    friend istream &operator >> (istream &is, Mod_Int &p){
        ll a;
        is >> a;
        p = Mod_Int<mod>(a);
        return is;
    }
};

using mint = Mod_Int<MOD>;

template<typename T>
struct Matrix{
    vector<vector<T>> A;

    Matrix(int n, int m) : A(n, vector<T>(m, 0)) {} //+の単位元

    int height() const {return sz(A);}

    int width() const {return sz(A.front());}

    inline const vector<T> &operator [] (int k) const {return A[k];}

    inline vector<T> &operator [] (int k) {return A[k];}

    static Matrix I(int l){
        Matrix ret(l, l);
        rep(i, l) ret[i][i] = 1; //*の単位元
        return ret;
    }

    Matrix &operator *= (const Matrix &B){
        int n = height(), m = width(), p = B.width();
        assert(m == B.height());
        Matrix tmp(n, p);
        rep(i, n){
            rep(k, m){
                rep(j, p) tmp.A[i][j] += A[i][k]*B[k][j];
            }
        }
        swap(A, tmp.A);
        return *this;
    }

    Matrix operator * (const Matrix &B) const {return Matrix(*this) *= B;}

    Matrix pow(ll k) const{
        int n = height(), m = width();
        assert(n == m);
        Matrix now = *this, ret = I(n);
        while(k){
            if(k&1) ret *= now;
            now *= now, k >>= 1;
        }
        return ret;
    }

    bool eq(T a, T b){
        //return a == b;
        return abs(a-b) <= EPS;
    }

    int normalize(){
        int n = height(), m = width(), check = 0, ret = 0;
        rep(j, m){
            int pivot = check;
            rep2(i, check, n-1){
                //if(A[i][j] != 0) pivot = i;
                if(abs(A[i][j]) > abs(A[pivot][j])) pivot = i;
            }
            swap(A[check], A[pivot]);
            if(eq(A[check][j], 0)) continue;
            ret++;
            rep2(k, j+1, m-1) A[check][k] /= A[check][j];
            A[check][j] = 1;
            rep(i, n){
                if(i == check) continue;
                rep2(k, j+1, m-1) A[i][k] -= A[i][j]*A[check][k];
                A[i][j] = 0;
            }
            if(++check == n) break;
        }
        return ret;
    }

    pair<int, Matrix> Gausiann_elimination(const Matrix &b){ //解無し:-1、不定解:0、唯一解:1
        int n = height(), m = width();
        assert(b.height() == n && b.width() == 1);
        rep(i, n) A[i].pb(b.A[i][0]);
        int rank = normalize();
        Matrix x(m, 1);
        rep(i, n){
            bool flag = true;
            rep(j, m) if(!eq(A[i][j], 0)) flag = false;
            if(eq(A[i][m], 0)) flag = false;
            if(flag) return make_pair(-1, x);
        }
        if(rank < m) return make_pair(0, x);
        rep(i, m) x.A[i][0] = A[i][m];
        return make_pair(1, x);
    }
};

int main(){
    Matrix<mint> A(32, 32);
    rep2(i, 0, 15){
        rep(j, 2){
            if(i <= 5 && j == 0){
                rep2(k, i+1, 6) A[2*k+1][2*i+j]++;
            }
            if(i == 5 && j == 1) A[13][2*i+j]++;
            if(6 <= i && i <= 13){
                rep2(k, i+1, (i&~1)+2) A[2*k+1][2*i+j]++;
            }
            if(i == 14) A[31][2*i+j]++;
            A[2*i+(j^1)][2*i+j]++;
        }
    }

    int T;
    cin >> T;

    while(T--){
        int N;
        cin >> N;
        Matrix<mint> x(32, 1);
        x[0][0] = 1;
        Matrix<mint> ret = A.pow(N+1)*x;
        cout << ret[30][0]+ret[31][0] << endl;
    }
}

Measured memory_bytes: 3684