#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>
#include <random>

long long int dfs(int dim, int N){
    if(dim == 0) return 1;
    long long int res = 0;
    for(int i = 0; i <= N; ++i){
        for(int j = i + 1; i + j <= N; ++j){
            res += (j - i) * dfs(dim - 1, N - i - j);
        }
    }
    return res;
}

// modint構造体
template <int modulus> struct mod_Int{
    int val; // 値本体
    // コンストラクタ
    constexpr mod_Int():val(0){}
   // constexpr mod_Int(const int& v):val(v % modulus){ if(val < 0) val += modulus; }
    //constexpr mod_Int(int&& v):val(v % modulus){ if(val < 0) val += modulus; }
    constexpr mod_Int(const long long int& v):val(v % modulus){ if(val < 0) val += modulus; }
    constexpr mod_Int(long long int&& v):val(v % modulus){ if(val < 0) val += modulus; }
    //constexpr mod_Int(const unsigned int& v):val(v % modulus){}
    //constexpr mod_Int(unsigned int&& v):val(v % modulus){}
    //constexpr mod_Int(const unsigned long long int& v):val(v % modulus){}
    //constexpr mod_Int(unsigned long long int&& v):val(v % modulus){}
    constexpr mod_Int& operator += (const mod_Int<modulus>& other) noexcept {
        val += other.val; if(val >= modulus) val -= modulus;
        return *this;
    }
    constexpr mod_Int& operator -= (const mod_Int<modulus>& other) noexcept {
        val -= other.val; if(val < 0) val += modulus;
        return *this;
    }
    constexpr mod_Int& operator *= (const mod_Int<modulus>& other) noexcept {
        val = static_cast<long long int>(val) * other.val % modulus;
        return *this; 
    }
    constexpr mod_Int& operator /= (const mod_Int<modulus>& other) noexcept {
        val = static_cast<long long int>(val) * other.inverse() % modulus;
        return *this;
    }
    constexpr bool operator == (const mod_Int<modulus>& other) const noexcept {
        return val == other.val;
    }
    constexpr mod_Int operator +(const mod_Int<modulus>& v) const noexcept{
        return mod_Int<modulus>(*this) += v;
    }
    constexpr mod_Int operator -(const mod_Int<modulus>& v)const noexcept{
        return mod_Int<modulus>(*this) -= v;
    }
    constexpr mod_Int operator *(const mod_Int<modulus>& v) const noexcept{
        return mod_Int<modulus>(*this) *= v;
    }
    constexpr mod_Int operator /(const mod_Int<modulus>& v) const noexcept{
        return mod_Int<modulus>(*this) /= v;
    }
    constexpr mod_Int& operator ++(void) noexcept {
        if(++val == modulus) val = 0;
        return *this;
    }
    constexpr mod_Int& operator --(void) noexcept {
        if(val-- == 0) val = modulus - 1;
        return *this;
    }
    constexpr mod_Int operator -()const noexcept{
        return mod_Int<modulus>((val == 0 ? 0 : modulus - val));
    }

    // aの逆元を求める関数
    static constexpr int inverse(int a) noexcept {
        int b = modulus, 
            u = 1, v = 0;
        while (b != 0) {
            const int t = a / b; 
            a -= t * b; std::swap(a, b);
            u -= t * v; std::swap(u, v);
        }
        if(u < 0) u += modulus;
        return u;
    }
    constexpr int inverse(void) const noexcept { return inverse(val); }
    // a^nを返す関数 : nは負の数でも可
    static constexpr int power(long long int a, long long int n){
        long long res = 1, waiting = a;
        if(n < 0) waiting = inverse(a), n = -n;
        while(n != 0){ 
            if(n % 2 != 0) res = res * waiting % modulus; 
            waiting = waiting * waiting % modulus; 
            n /= 2;
        }
        return res;
    }
    constexpr mod_Int power(long long int n) const noexcept { mod_Int res; res.val = power(val, n); return res; }
};

constexpr int mod = 1'000'000'007;
using modint = mod_Int<mod>;

void solve(void){
    int n; std::cin >> n; 
    if(n < 5){
      std::cout << "0\n"; return;
    }
    n -= 5;
    modint x; x.val = n;
    modint a = (n & 1) ? -1 : 1;
    modint res = 0;
    res += modint(8) * x.power(15);
    res += modint(1260) *  x.power(14);
    res += modint(90440) * x.power(13);
    res += modint(3917550) * x.power(12);
    res += modint(114299276) *  x.power(11);
    res += modint(2373901530) * x.power(10);
    res += modint(36162575020) * x.power(9);
    res += modint(410183373600) * x.power(8);
    res += modint(3480294641824) * x.power(7);
    res += modint(21993956144160) * x.power(6);
    res += modint(102141744053440) * x.power(5);
    res += modint(47775) * ( modint(4455) * a + modint(7118899609)) * x.power(4);
    res += modint(18) *  ( modint(496621125) * a + modint(43303045234619)) * x.power(3);
    res += modint(4725) * ( modint(28603575) * a + modint(242967305033)) * x.power(2);
    res += modint(28350) * ( modint(30585555) * a + modint(33755499821)) * x;
    res += modint(1277025750) * ( modint(1549) * a + modint(260595) ) ;
    res *= 3; res /= 32;
    modint t = 1;
    for(int i = 2; i <= 4; ++i) t *= modint(i);
    for(int i = 2; i <= 15; ++i) t *= modint(i);
    res /= t;
    std::cout << res.val << '\n';
}


int main(void){
    std::cin.tie(nullptr); std::cin.sync_with_stdio(false);
    int T; std::cin >> T;
    while(T--) solve();
    return 0;
}

Measured memory_bytes: 3648