Problem:
Score : 600 points

Problem Statement

Given is an integer N. Snuke will choose integers s_1, s_2, n_1, n_2, u_1, u_2, k_1, k_2, e_1, and e_2 so that all of the following six conditions will be satisfied:

0 \leq s_1 < s_2

0 \leq n_1 < n_2

0 \leq u_1 < u_2

0 \leq k_1 < k_2

0 \leq e_1 < e_2

s_1 + s_2 + n_1 + n_2 + u_1 + u_2 + k_1 + k_2 + e_1 + e_2 \leq N

For every possible choice (s_1,s_2,n_1,n_2,u_1,u_2,k_1,k_2,e_1,e_2), compute (s_2 − s_1)(n_2 − n_1)(u_2 − u_1)(k_2 - k_1)(e_2 - e_1), and find the sum of all computed values, modulo (10^{9} +7).

Solve this problem for each of the T test cases given.

Constraints

All values in input are integers.

1 \leq T \leq 100

1 \leq N \leq 10^{9}

Input

Input is given from Standard Input in the following format:

T
\mathrm{case}_1
\vdots
\mathrm{case}_T

Each case is given in the following format:

N

Output

Print T lines. The i-th line should contain the answer to the i-th test case.

Sample Input 1

4
4
6
10
1000000000

Sample Output 1

0
11
4598
257255556

When N=4, there is no possible choice (s_1,s_2,n_1,n_2,u_1,u_2,k_1,k_2,e_1,e_2). Thus, the answer is 0.

When N=6, there are six possible choices (s_1,s_2,n_1,n_2,u_1,u_2,k_1,k_2,e_1,e_2) as follows:

(0,1,0,1,0,1,0,1,0,1)

(0,2,0,1,0,1,0,1,0,1)

(0,1,0,2,0,1,0,1,0,1)

(0,1,0,1,0,2,0,1,0,1)

(0,1,0,1,0,1,0,2,0,1)

(0,1,0,1,0,1,0,1,0,2)

We have one choice where (s_2 − s_1)(n_2 − n_1)(u_2 − u_1)(k_2 - k_1)(e_2 - e_1) is 1 and five choices where (s_2 − s_1)(n_2 − n_1)(u_2 − u_1)(k_2 - k_1)(e_2 - e_1) is 2, so the answer is 11.

Be sure to find the sum modulo (10^{9} +7).

Solution in C++ (GCC 9.2.1) (judge verdict: Accepted)

// May this submission get accepted
#include <bits/stdc++.h>

// エイリアス
using  ll = long signed long;
using ull = long unsigned long;
using  ld = long double;
using namespace std;

// AtCoder/Codeforces 用 デバッグ検知
#ifdef ONLINE_JUDGE
constexpr bool DEBUG_MODE = false;
#else
constexpr bool DEBUG_MODE = true;
#endif

// エイリアス (補完・コンパイルが重くなる)
// #include <boost/multiprecision/cpp_int.hpp>
// using mll = boost::multiprecision::cpp_int;

// 汎用マクロ
#define ALLOF(x) (x).begin(), (x).end()
#define REP(i,n) for (long long i=0, i##_len=(n); i<i##_len; i++)
#define RANGE(i,is,ie) for (long long i=(is), i##_end=(ie); i<=i##_end; i++)
#define DSRNG(i,is,ie) for (long long i=(is), i##_end=(ie); i>=i##_end; i--)
#define STEP(i, is, ie, step) for (long long i=(is), i##_end=(ie), i##_step = (step); i<=i##_end; i+=i##_step)
#define UNIQUE(v) do { sort((v).begin(), (v).end()); (v).erase(unique((v).begin(), (v).end()), (v).end()); } while (false)
#define FOREACH(i,q) for (auto &i : q)
template<typename T, typename U> bool chmax(T &a, const U b) { if (a < b) {a = b; return true;} return false; }
template<typename T, typename U> bool chmin(T &a, const U b) { if (a > b) {a = b; return true;} return false; }
constexpr int INF = numeric_limits<int>::max();
constexpr long long LINF = numeric_limits<long long>::max();
constexpr long double EPS = 1e-10L;
#define Yes(q) ((q) ? "Yes" : "No")
#define YES(q) ((q) ? "YES" : "NO")
#define Possible(q) ((q) ? "Possible" : "Impossible")
#define POSSIBLE(q) ((q) ? "POSSIBLE" : "IMPOSSIBLE")
#define IIF(q,t,f) ((q) ? (t) : (f))
#define DUMP(q) DUMP_FUNC(q, #q, __FILE__, __LINE__)
template <typename T> void DUMP_PROC(T x) { if (is_integral<T>() || is_floating_point<T>()) cerr << "\e[32m" << x << "\e[m"; else cerr << x; }
template<> void DUMP_PROC<char>(char x) { cerr << "\e[36m\'" << x << "\'\e[m"; }
template<> void DUMP_PROC<string>(string x) { cerr << "\e[33m\"" << x << "\"\e[m"; }
template <typename T, typename U> void DUMP_PROC(pair<T, U> x) { cerr << "{"; DUMP_PROC(x.first); cerr << ", "; DUMP_PROC(x.second); cerr << "}"; }
template <typename ...T, typename U, U... Seq> void DUMP_PROC(tuple<T...> &x, integer_sequence<U, Seq...>) { (void)(int[]){(cerr << ((const char*[]){"", ", "})[!!Seq] << (DUMP_PROC(get<Seq>(x)), ""), 0)...}; }
template <typename ...T> void DUMP_PROC(tuple<T...> x) {cerr << "{"; DUMP_PROC(x, index_sequence_for<T...>()); cerr << "}";}
template <typename T> void DUMP_PROC(vector<T> x) { cerr << "["; for (auto &xi : x) { DUMP_PROC(xi); cerr << (&xi != &*x.rbegin()?", ":""); } cerr << "]"; }
template <typename T> void DUMP_FUNC(T x, const char* name, const char* fn, int ln) { cerr << "\e[32m[DEBUG]\e[m " << name << ": "; DUMP_PROC(x); cerr << " @ " << fn << "(" << ln << ")" << endl; }

// gcc拡張マクロ
#define popcount __builtin_popcount
#define popcountll __builtin_popcountll

// 標準入出力
struct qin { // query input
    size_t sz;
    qin(size_t _sz = 1) : sz(_sz) {}
    template <typename T> operator T () const { T a; cin >> a; return a; }
    template <typename T> operator vector<T> () const { vector<T> a(sz); for (size_t i = 0; i < sz; i++) cin >> a[i]; return a; }
    template <typename T, typename U> operator pair<T, U> () const { T f; U s; cin >> f >> s; return pair<T, U>(f, s); }
};
qin in1; // input one
template <typename T> void say(const T x, const char* end = "\n") { cout << x << end; }
void say(const ld x, const char* end = "\n") { cout << setprecision(30) << x << end; }
template <typename T> void say(const vector<T> x, const char* sep = " ", const char* end = "\n") { REP(i, x.size()) { cout << x[i] << (i+1 == i_len ? end : sep); } }
template <typename T> void say(const vector<vector<T>> x, const char* sep = " ", const char* end = "\n") { REP(i, x.size()) { say(x[i], sep, end); } }

// モジュール
// [[LIBRARY]] fps.cpp linalg2.cpp
// [Inclusion] modint_petit.cpp
// 剰余演算ライブラリ (小): 剰余と逆元だけ欲しいときに使う軽量ライブラリ
// mod pdiv 上での a^n
ll modpow(const ll a, ll n, const ll pdiv) {
    if (a == 0) return 0;
    ll r = 1;
    ((n %= pdiv-1) += pdiv-1) %= pdiv-1; // a^(p-1) === a^0 mod pdiv
    for (ll b = (a % pdiv + pdiv) % pdiv; n; n >>= 1, (b *= b) %= pdiv) if (n & 1) (r *= b) %= pdiv;
    return r;
}
inline ll modinv(const ll a, const ll pdiv) { return modpow(a, pdiv-2, pdiv); }

// [Inclusion] garner.cpp
// Garnerのアルゴリズム O(|w|^2)
// w[i] = {x[i], m[i]} とすると {x === x[i] mod m[i]} から x mod pdiv を復元
// w[i].second (m[i]) は pairwise 互いに素である必要がある
ll garner (const vector<pair<ll, ll>> &w, const ll pdiv) {
    vector<ll> p(w.size()+1, 1);
    vector<ll> v(w.size()+1, 0);
    for (size_t k = 0; k < w.size(); k++) {
        ll xk, mk; tie(xk, mk) = w[k];
        ll t = ((xk - v[k]) % mk + mk) % mk * modinv(p[k], mk) % mk;
        for (size_t i = k+1; i <= w.size(); i++) {
            ll bi = i == w.size() ? pdiv : w[i].second;
            (v[i] += t * p[i]) %= bi;
            (p[i] *= w[k].second) %= bi;
        }
    }
    return v.back();
};

// [Inclusion] ntt.cpp
// 精度に寄りけりだがconv1回で済むFFTの方がいい場合もあることに留意
// Cooley-Tukey型 高速フーリエ変換 O(NlogN)
template <ll pdiv = 998244353, ll prim = 3>
void ntt_inplace(vector<ll> &a, const bool inv = false) {
    // Shita-goshirae
    ll n = 1, h = 0;
    while (n < a.size()) n <<= 1, h++;
    a.resize(n, 0);
    for (size_t i = 0; i < n; i++) {
        ((a[i] %= pdiv) += pdiv) %= pdiv;
    }
    // Cooley-Tukey sort
    for (size_t i = 0; i < n; i++) {
        size_t j = 0;
        for (size_t k = 0; k < h; k++) {
            j |= (i >> k & 1) << (h-1 - k);
        }
        if (i < j) swap(a[i], a[j]);
    }
    // butterfly enzan
    for (size_t b = 1; b < n; b <<= 1) {
        const ll root = modpow(prim, (pdiv-1) / (b << 1) * (inv ? -1 : 1), pdiv);
        ll w = 1;
        for (size_t j = 0; j < b; j++) {
            for (size_t k = 0; k < n; k += b << 1) {
                ll s = a[j+k  ];
                ll t = a[j+k+b] * w % pdiv;
                a[j+k  ] = (s+t) % pdiv;
                a[j+k+b] = (s-t + pdiv) % pdiv;
            }
            (w *= root) %= pdiv;
        }
    }
    if (inv) {
        const ll invn = modinv(n, pdiv);
        for (ll i = n; i--; ) (a[i] *= invn) %= pdiv;
    }
}
template <ll pdiv = 998244353, ll prim = 3>
inline vector<ll> ntt(vector<ll> a, const bool inv = false) { ntt_inplace<pdiv, prim>(a, inv); return a; }
// 適切な原始根の存在する法での畳み込み
template <ll pdiv, ll prim>
vector<ll> convolve_p(const vector<ll> &x, const vector<ll> &y) {
    size_t t = x.size() + y.size() - 1;
    auto a = x; a.resize(t, 0);
    auto b = y; b.resize(t, 0);
    ntt_inplace<pdiv, prim>(a);
    ntt_inplace<pdiv, prim>(b);
    for (size_t i = 0; i < a.size(); i++) (a[i] *= b[i]) %= pdiv;
    ntt_inplace<pdiv, prim>(a, true);
    a.resize(t);
    return a;
}
// 任意MODでの畳み込み演算
vector<ll> convolve(const vector<ll> &x, const vector<ll> &y, const ll pdiv) {
    if (pdiv == 998244353) return convolve_p<998244353, 3>(x, y);
    const auto conv1 = convolve_p<1224736769, 3>(x, y);
    // const auto conv2 = convolve_p<998244353, 3>(x, y);
    const auto conv3 = convolve_p<469762049, 3>(x, y);
    const auto conv4 = convolve_p<167772161, 3>(x, y);
    ll n = conv1.size();
    ll t = x.size() + y.size() - 1;
    vector<ll> result(t, 0);
    for (ll i = 0; i < t; i++) {
        vector<pair<ll, ll>> g = {
            {conv1[i], 1224736769},
            // {conv2[i], 998244353},
            {conv3[i], 469762049},
            {conv4[i], 167772161}
        };
        result[i] = garner(g, pdiv);
    }
    return result;
}

// [Inclusion] linalg2.cpp
// 行列演算
// pdivの余りを取りたくない場合はoperator+=/-=/*のコメントアウトを適宜
constexpr ll pdiv = 1000000007LL;

template <typename T = ll>
class matrix {
private:
    size_t col_size, row_size;
    vector<T> raw;
public:
    matrix() : col_size(0), row_size(0), raw() {}
    matrix(size_t n) : col_size(1), row_size(n), raw(n, 0) {}
    matrix(size_t n, size_t m) : col_size(m), row_size(n), raw(n * m, 0) {}
    matrix(const vector<vector<T>> &a) : col_size(a.size() ? a[0].size() : 0), row_size(a.size()), raw(col_size * row_size) {
        for (size_t i = 0; i < row_size; i++) {
            for (size_t j = 0; j < col_size; j++) {
                at(i, j) = a[i][j];
            }
        }
    }
    matrix(initializer_list<T> init) : col_size(init.size()), row_size(1), raw(init) {}
    matrix(initializer_list<initializer_list<T>> init) : col_size(0), row_size(0), raw() {
        const size_t n = init.size();
        const size_t m = [&]() {
            size_t maxm = 0;
            for (const auto& initi : init) {
                const size_t mi = initi.size();
                if (mi > maxm) maxm = mi;
            }
            return maxm;
        }();
        tie(row_size, col_size) = make_pair(n, m);
        raw.resize(n * m);
        size_t i = 0, j = 0;
        for (const auto &initi : init) {
            for (const auto &v : initi) {
                at(i, j++) = v;
            }
            i++; j = 0;
        }
    }
    size_t rows() const { return row_size; }
    size_t cols() const { return col_size; }
    const T& at(const size_t i, const size_t j) const { return raw.at(i * col_size + j); }
    const T& at(const size_t i) const { return raw.at(i); }
    T& at(const size_t i, const size_t j) { return raw.at(i * col_size + j); }
    T& at(const size_t i) { return raw.at(i); }
    T& operator() (size_t i, size_t j) { return raw[i * col_size + j]; }
    T& operator() (size_t i) { return raw[i]; }
    T& operator[] (size_t i) { return raw[i]; }
    const T& operator() (size_t i, size_t j) const { return raw[i * col_size + j]; }
    const T& operator() (size_t i) const { return raw[i]; }
    const T& operator[] (size_t i) const { return raw[i]; }
    matrix<T>& operator+= (const matrix<T> &a) {
        for (size_t i = 0; i < row_size; i++) {
            for (size_t j = 0; j < col_size; j++) {
                // at(i, j) += a.at(i, j);
                if ((at(i, j) += a.at(i, j)) >= pdiv) at(i, j) -= pdiv;
            }
        }
        return *this;
    }
    matrix<T>& operator-= (const matrix<T> &a) {
        for (size_t i = 0; i < row_size; i++) {
            for (size_t j = 0; j < col_size; j++) {
                // at(i, j) -= a.at(i, j);
                if ((at(i, j) +=  pdiv - a.at(i, j)) >= pdiv) at(i, j) -= pdiv;
            }
        }
        return *this;
    }
    matrix<T> operator* (const matrix<T> &a) {
        assert(col_size == a.row_size);
        const size_t n = row_size, m = col_size, q = a.col_size;
        matrix<T> r(n, q);
        for (size_t i = 0; i < n; i++) {
            for (size_t k = 0; k < m; k++) {
                for (size_t j = 0; j < q; j++) {
                    // r.at(i, j) += at(i, k) * a.at(k, j);
                    (r.at(i, j) += at(i, k) * a.at(k, j) % pdiv) %= pdiv;
                }
            }
        }
        return r;
    }
    
    matrix<T> operator+ (const matrix<T> &a) const {
        matrix<T> r = *this;
        return r += a;
    }
    matrix<T> operator- (const matrix<T> &a) const {
        matrix<T> r = *this;
        return r -= a;
    }
    matrix<T>& operator*= (const matrix<T> &a) {
        return *this = move(*this * a);
    }
    operator T () const {
        assert(col_size == 1 && row_size == 1);
        return raw[0];
    }
    static matrix<T> eye(size_t n) {
        matrix<T> r(n, n);
        for (size_t i = 0; i < n; i++)
            r.at(i, i) = 1;
        return r;
    }
    matrix<T> transpose() const {
        matrix<T> r(col_size, row_size);
        for (size_t i = 0; i < col_size; i++) {
            for (size_t j = 0; j < row_size; j++) {
                r.at(i, j) = at(j, i);
            }
        }
        return r;
    }
    matrix<T> pow(long long int n) const {
        assert(row_size == col_size);
        matrix<T> r = eye(row_size);
        matrix<T> a = *this;
        while (n) {
            if (n & 1) r *= a;
            n /= 2;
            if (n) a *= a;
        }
        return r;
    }
};
template <typename T>
void DUMPMTR(matrix<T> m) {
    cerr << "[DEBUG] DUMPMTR: " << endl;
    for (size_t i = 0; i < m.rows(); i++) {
        cerr << " ["[!i] << "[";
        for (size_t j = 0; j < m.cols(); j++) {
            cerr << setw(4) << m(i, j) << " ]"[j+1 == m.cols()];
        }
        if (i+1 == m.rows()) cerr << ']';
        cerr << endl;
    }
}

// [Inclusion] fps.cpp
struct fps {
    vector<ll> coeff;
    ll pdiv = 1000000007LL; // 適宜変更のこと，一度生成したら変えないこと
    fps(const ll x = 0): coeff(1, x) {}
    fps(const initializer_list<ll> &x): coeff(x) { FOREACH(c, coeff) c = (c % pdiv + pdiv) % pdiv; }
    fps(const vector<ll> &x): coeff(x) { FOREACH(c, coeff) c = (c % pdiv + pdiv) % pdiv; }
    size_t size() const { return coeff.size(); }
    void resize(size_t deg) { coeff.resize(deg, 0); }
    fps pow(size_t n, size_t deg) const {
        if (n == 0) return fps(1);
        if (n == 1) return fps(coeff);
        if (n < 0) return this->pow(-n, deg).inv(deg);
        vector<ll> rs = {1};
        vector<ll> bs = coeff;
        for (size_t mask = n; mask; mask >>= 1) {
            if (mask & 1) {
                rs = convolve(bs, rs, pdiv);
                if (rs.size() > deg) rs.resize(deg);
            }
            bs = convolve(bs, bs, pdiv);
            if (bs.size() > deg) bs.resize(deg);
        }
        rs.resize(deg);
        return fps(rs);
    }
    fps inv(size_t deg = 0) const {
        if (!deg) deg = size();
        assert(coeff.front() != 0);
        vector<ll> rs = {modinv(coeff.front(), pdiv)};
        for (size_t i = 1; i < deg; i *= 2) {
            auto rs2 = rs; for (ll &rsi : rs2) (rsi *= 2) %= pdiv;
            auto rss = convolve(rs, rs, pdiv);
            vector<ll> as(i*2, 0);
            REP(j, min<ll>(i*2, coeff.size())) as[j] = (coeff[j] % pdiv + pdiv) % pdiv;
            auto rcv = convolve(rss, as, pdiv);
            rs .resize(i*2, 0);
            rs2.resize(i*2, 0);
            rcv.resize(i*2, 0);
            for (size_t j = 0; j < i*2; j++) {
                rs[j] = (rs2[j] - rcv[j] + pdiv) % pdiv;
            }
        }
        rs.resize(deg);
        return fps(rs);
    }
    fps operator* (const fps &a) const { assert(pdiv == a.pdiv); auto f = fps(convolve(coeff, a.coeff, pdiv)); f.resize(max(size(), a.size())); return f; }
    fps& operator*= (const fps &a) { size_t sz = max(size(), a.size()); coeff = convolve(coeff, a.coeff, pdiv); resize(sz); return *this; }
    fps& operator+= (const fps &a) { assert(pdiv == a.pdiv); resize(max(size(), a.size())); REP(i, min(size(), a.size())) (coeff[i] += a.coeff[i]) %= pdiv; return *this; }
    fps operator+ (const fps &a) const { fps rs = *this; return rs += a; }
    fps& operator-= (const fps &a) { assert(pdiv == a.pdiv); resize(max(size(), a.size())); REP(i, min(size(), a.size())) (coeff[i] += pdiv - a.coeff[i]) %= pdiv; return *this; }
    fps operator- (const fps &a) const { fps rs = *this; return rs -= a; }
    fps operator/ (const fps &a) const { assert(pdiv == a.pdiv); return *this * a.inv(max(a.size(), size())); }
    fps operator/= (const fps &a) { assert(pdiv == a.pdiv); return *this *= a.inv(max(a.size(), size())); }
};
fps operator"" _fps(unsigned long long _x) { return fps(_x); }
ostream& operator<< (ostream& ost, const fps& a) {
    ost << "[";
    for (size_t i = 0; i < a.size(); i++) {
        ost << a.coeff[i] << (i+1 == a.size() ? "]" : ", ");
    }
    return ost;
}

// [[/LIBRARY]]

// 処理内容
int main() {
    
    ios::sync_with_stdio(false); // stdioを使うときはコメントアウトすること
    cin.tie(nullptr);            // インタラクティブ問題ではコメントアウトすること

    ll t = in1;

    fps a = {0, 1};
    fps b = {1, -1};
    fps c = {1, 1};

    fps y = b.pow(16, 32) * c.pow(5, 32);

    a.resize(32);
    auto z = a / y;

    matrix f(21, 21);
    REP(i, 21) {
        f.at(0, i) = (pdiv - y.coeff[i+1]) % pdiv;
    }
    REP(i, 20) {
        f.at(i+1, i) = 1;
    }

    matrix x(21);
    REP(i, 21) {
        x.at(20-i) = z.coeff[i];
    }

    REP(caseno, t) {
    
        ll n = in1;

        if (n < 5) {
            say(0);
            continue;
        }

        say((f.pow(n-4) * x).at(20));

    }

}