#include <bits/stdc++.h>
using namespace std;

#define int long long
#define rep(i, n) for (int i = 0; i < (int) (n); i++)
#define reps(i, n) for (int i = 1; i <= (int) (n); i++)
#define all(x) (x).begin(), (x).end()
#define uniq(x) (x).erase(unique(all(x)), (x).end())
#define bit(n) (1LL << (n))
#define dump(x) cerr << #x " = " << (x) << endl
using vint = vector<int>;
using vvint = vector<vint>;
using pint = pair<int, int>;
using vpint = vector<pint>;
template<typename T> using priority_queue_rev = priority_queue<T, vector<T>, greater<T>>;
constexpr double PI = 3.1415926535897932384626433832795028;
constexpr int DY[9] = {0, 1, 0, -1, 1, 1, -1, -1, 0};
constexpr int DX[9] = {1, 0, -1, 0, 1, -1, -1, 1, 0};
int sign(int x) { return (x > 0) - (x < 0); }
int gcd(int a, int b) {
    while (b) { swap(a %= b, b); }
    return a;
}
int lcm(int a, int b) { return a / gcd(a, b) * b; }
int cdiv(int a, int b) { return (a - 1 + b) / b; }
template<typename T> void fin(T mes) {
    cout << mes << endl;
    exit(0);
}
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 (b < a) {
        a = b;
        return true;
    }
    return false;
}
template<typename T, typename U> ostream &operator<<(ostream &os, const pair<T, U> &rhs) {
    os << "(" << rhs.first << ", " << rhs.second << ")";
    return os;
}
template<typename T> ostream &operator<<(ostream &os, const vector<T> &rhs) {
    os << "{";
    for (auto itr = rhs.begin(); itr != rhs.end(); itr++) {
        os << *itr << (next(itr) != rhs.end() ? ", " : "");
    }
    os << "}";
    return os;
}
template<typename T> ostream &operator<<(ostream &os, const deque<T> &rhs) {
    os << "{";
    for (auto itr = rhs.begin(); itr != rhs.end(); itr++) {
        os << *itr << (next(itr) != rhs.end() ? ", " : "");
    }
    os << "}";
    return os;
}
template<typename T> ostream &operator<<(ostream &os, const set<T> &rhs) {
    os << "{";
    for (auto itr = rhs.begin(); itr != rhs.end(); itr++) {
        os << *itr << (next(itr) != rhs.end() ? ", " : "");
    }
    os << "}";
    return os;
}
template<typename T, typename U> ostream &operator<<(ostream &os, const map<T, U> &rhs) {
    os << "{";
    for (auto itr = rhs.begin(); itr != rhs.end(); itr++) {
        os << *itr << (next(itr) != rhs.end() ? ", " : "");
    }
    os << "}";
    return os;
}
struct setup {
    static constexpr int PREC = 20;
    setup() {
        cout << fixed << setprecision(PREC);
        cerr << fixed << setprecision(PREC);
    };
} setup;

template<int MOD = 1000000007>
struct mod_int {
    int val;
    mod_int(long long val_ = 0) : val(val_ % MOD) { if (val < 0) { val += MOD; }}
    bool operator==(const mod_int &rhs) const { return val == rhs.val; }
    bool operator!=(const mod_int &rhs) const { return std::rel_ops::operator!=(*this, rhs); }
    mod_int &operator+=(const mod_int &rhs) {
        if ((val += rhs.val) >= MOD) { val -= MOD; }
        return *this;
    }
    mod_int &operator-=(const mod_int &rhs) {
        if ((val += MOD - rhs.val) >= MOD) { val -= MOD; }
        return *this;
    }
    mod_int &operator*=(const mod_int &rhs) {
        val = (int) ((long long) val * rhs.val % MOD);
        return *this;
    }
    mod_int &operator/=(const mod_int &rhs) { return *this *= rhs.inv(); }
    mod_int operator+() const { return *this; }
    mod_int operator-() const { return -val; }
    mod_int operator++() { return *this += 1; }
    mod_int operator--() { return *this -= 1; }
    mod_int operator++(signed) {
        const mod_int ret(*this);
        ++*this;
        return ret;
    }
    mod_int operator--(signed) {
        const mod_int ret(*this);
        --*this;
        return ret;
    }
    mod_int operator+(const mod_int &rhs) const { return mod_int(*this) += rhs; }
    mod_int operator-(const mod_int &rhs) const { return mod_int(*this) -= rhs; }
    mod_int operator*(const mod_int &rhs) const { return mod_int(*this) *= rhs; }
    mod_int operator/(const mod_int &rhs) const { return mod_int(*this) /= rhs; }
    mod_int inv() const {
        assert(val != 0);
        int a = val, b = MOD, x = 1, u = 0;
        while (b) {
            int t = a / b;
            std::swap(a -= t * b, b);
            std::swap(x -= t * u, u);
        }
        return x;
    }
    mod_int pow(long long n) const {
        if (n < 0) { return pow(-n).inv(); }
        mod_int ret = 1, mul = *this;
        while (n) {
            if (n & 1) { ret *= mul; }
            mul *= mul;
            n >>= 1;
        }
        return ret;
    }
    friend std::istream &operator>>(std::istream &is, mod_int &rhs) {
        long long v;
        is >> v;
        rhs = v;
        return is;
    }
    friend std::ostream &operator<<(std::ostream &os, const mod_int &rhs) { return os << rhs.val; }
    struct combination {
        std::vector<mod_int> fact{1, 1}, f_inv{1, 1}, inv{0, 1};
        void calc(int n) {
            while (fact.size() <= n) {
                int i = fact.size();
                fact.push_back(fact[i - 1] * i);
                inv.push_back(-inv[MOD % i] * (MOD / i));
                f_inv.push_back(f_inv[i - 1] * inv[i]);
            }
        }
        mod_int P(int n, int r) { return r < 0 || n < r ? 0 : (calc(n), fact[n] * f_inv[n - r]); }
        mod_int C(int n, int r) { return r < 0 || n < r ? 0 : (calc(n), fact[n] * f_inv[r] * f_inv[n - r]); }
        mod_int H(int n, int r) { return C(n + r - 1, r); }
    };
};

template<typename T> void fft(std::vector<T> &x, const std::vector<T> &w) {
    int n = x.size();
    int m = n >> 1;
    std::vector<T> y(n);
    for (int i = 1; i <= m; i <<= 1) {
        for (int j = 0; j < m; j += i) {
            for (int k = 0; k < i; k++) {
                int u = j + k;
                y[(u << 1) + 0] = (x[u + 0] + x[u + m]);
                y[(u << 1) + 1] = (x[u + 0] - x[u + m]) * w[j];
            }
        }
        std::swap(x, y);
    }
}

template<typename T> void ifft(std::vector<T> &x, const std::vector<T> &w) {
    int n = x.size();
    int m = n >> 1;
    std::vector<T> y(n);
    for (int i = m; i > 0; i >>= 1) {
        for (int j = 0; j < m; j += i) {
            for (int k = 0; k < i; k++) {
                int u = j + k;
                x[(u << 1) + 1] *= w[j];
                y[u + 0] = x[(u << 1) + 0] + x[(u << 1) + 1];
                y[u + m] = x[(u << 1) + 0] - x[(u << 1) + 1];
            }
        }
        std::swap(x, y);
    }
    T n_inv = T(1) / n;
    for (int i = 0; i < n; i++) { x[i] *= n_inv; }
}

template<int MOD, int ROOT>
std::vector<int> friendly_mod_convolute(const std::vector<int> &a, const std::vector<int> &b) {
    int n_a = a.size(), n_b = b.size();
    int n_ = n_a + n_b - 1, n;
    for (n = 1; n < n_; n <<= 1) {}
    int m = n >> 1;
    std::vector<mod_int<MOD>> a_mint(n), b_mint(n), w(m + 2);
    std::copy(a.begin(), a.end(), a_mint.begin()), std::copy(b.begin(), b.end(), b_mint.begin());
    w[0] = 1, w[1] = mod_int<MOD>(ROOT).pow((MOD - 1) / n);
    for (int i = 2; i < m; i++) { w[i] = w[i - 1] * w[1]; }
    fft(a_mint, w);
    fft(b_mint, w);
    for (int i = 0; i < n; i++) { a_mint[i] *= b_mint[i]; }
    w[1] = w[1].inv();
    for (int i = 2; i < m; i++) { w[i] = w[i - 1] * w[1]; }
    ifft(a_mint, w);
    std::vector<int> ret(n_);
    for (int i = 0; i < n_; i++) { ret[i] = a_mint[i].val; }
    return ret;
}

template<int K = 3>
std::vector<int> arbitrary_mod_convolute(const std::vector<int> &a, const std::vector<int> &b, int mod) {
    static constexpr int MS[] = {998244353, 469762049, 167772161}, RS[] = {3, 3, 3};
    auto safe_mod = [](int a, int m) -> int {
        a %= m;
        if (a < 0) { a += m; }
        return a;
    };
    auto mod_inv = [&](int a, int m) -> int {
        int b = m, x = 1, u = 0;
        while (b) {
            int t = a / b;
            std::swap(a -= t * b, b);
            std::swap(x -= t * u, u);
        }
        return safe_mod(x, m);
    };
    int n_a = a.size(), n_b = b.size();
    int n_ = n_a + n_b - 1, n;
    for (n = 1; n < n_; n <<= 1) {}
    std::vector<int> m(K + 1), prod_m(K + 1, 1);
    std::vector<std::vector<int>> ret(K + 1, std::vector<int>(n_));
    std::copy(MS, MS + K, m.begin());
    m[K] = mod;
    for (int i = 0; i < K; i++) {
        std::vector<int> piece;
        if (i == 0) { piece = friendly_mod_convolute<MS[0], RS[0]>(a, b); }
        if (i == 1) { piece = friendly_mod_convolute<MS[1], RS[1]>(a, b); }
        if (i == 2) { piece = friendly_mod_convolute<MS[2], RS[2]>(a, b); }
        int prod_inv = mod_inv(prod_m[i], m[i]);
        for (int j = 0; j < n_; j++) {
            int mod_m_i = (long long) safe_mod(piece[j] - ret[i][j], m[i]) * prod_inv % m[i];
            for (int k = i + 1; k <= K; k++) {
                ret[k][j] = (ret[k][j] + (long long) mod_m_i * prod_m[k] % m[k]) % m[k];
            }
        }
        for (int j = i + 1; j <= K; j++) { prod_m[j] = (long long) prod_m[j] * m[i] % m[j]; }
    }
    return ret[K];
}

using mint = mod_int<>;
mint::combination comb;

mint B[110];
void calc_B(int n) {
    B[0] = 1;
    reps(i, n) {
        rep(j, i) { B[i] += comb.C(i + 1, j) * B[j]; }
        B[i] /= -(i + 1);
    }
    B[1] = mint(2).inv();
}

vector<mint> operator+(const vector<mint> &lhs, const vector<mint> &rhs) {
    vector<mint> ret(max(lhs.size(), rhs.size()));
    rep(i, lhs.size()) { ret[i] += lhs[i]; }
    rep(i, rhs.size()) { ret[i] += rhs[i]; }
    return ret;
}

vector<mint> operator*(const vector<mint> &lhs, const vector<mint> &rhs) {
    vint a(lhs.size()), b(rhs.size());
    rep(i, lhs.size()) { a[i] = lhs[i].val; }
    rep(i, rhs.size()) { b[i] = rhs[i].val; }
    vint c = arbitrary_mod_convolute(a, b, 1e9 + 7);
    vector<mint> ret(c.size());
    rep(i, c.size()) { ret[i] = c[i]; }
    return ret;
}

vector<mint> S(int n) {
    vector<mint> ret(n + 2);
    rep(i, n + 1) { ret[n + 1 - i] = comb.C(n + 1, i) * B[i] / (n + 1); }
    return ret;
}

vector<mint> S(const vector<mint> &a) {
    vector<mint> ret;
    rep(i, a.size()) { ret = ret + vector<mint>({a[i]}) * S(i); }
    return ret;
}

mint sub(const vector<mint> &a, mint x) {
    mint ret;
    rep(i, a.size()) { ret += a[i] * x.pow(i); }
    return ret;
}

signed main() {
    calc_B(100);
    int T;
    cin >> T;
    while (T--) {
        int N;
        cin >> N;
        mint ans = 0;
        rep(i, 5 + 1) {
            queue<int> q;
            rep(j, i) { q.emplace(1); }
            rep(j, 5 - i) { q.emplace(0); }
            vector<mint> res;
            if (q.front() == 0) { res = {0, 1, 1}; }
            else { res = {0, 0, 1}; }
            q.pop();
            while (!q.empty()) {
                vector<mint> nxt;
                nxt = nxt + S(res) * vector<mint>({0, 0, 1});
                nxt = nxt + S(res * vector<mint>({0, 1})) * vector<mint>({0, -2});
                nxt = nxt + S(res * vector<mint>({0, 0, 1}));
                if (q.front() == 0) {
                    nxt = nxt + S(res) * vector<mint>({0, 1});
                    nxt = nxt + S(res * vector<mint>({0, -1}));
                }
                q.pop();
                swap(res, nxt);
            }
            int M = (N + i) / 2;
            ans += sub(S(res), M) * comb.C(5, i);
        }
        cout << ans << endl;
    }
}


Measured memory_bytes: 3660