#include <bits/stdc++.h>

using namespace std;

using ll = long long;

constexpr char newl = '\n';

// https://noshi91.hatenablog.com/entry/2019/03/31/174006
template <std::uint_fast64_t Modulus>
struct ModInt {
    using u64 = std::uint_fast64_t;

    static constexpr u64 MOD = Modulus;

    u64 val;

    constexpr ModInt(const u64 x = 0) noexcept : val(x % MOD) {}

    constexpr ModInt operator+() const noexcept { return ModInt(*this); }
    constexpr ModInt operator-() const noexcept {
        ModInt res(*this);
        if (res.val != 0) res.val = MOD - res.val;
        return res;
    }

    constexpr bool operator==(const ModInt& rhs) const noexcept { return val == rhs.val; }
    constexpr bool operator!=(const ModInt& rhs) const noexcept { return val != rhs.val; }

    // prefix increment/decrement
    constexpr ModInt& operator++() noexcept { return *this += ModInt(1); }
    constexpr ModInt& operator--() noexcept { return *this -= ModInt(1); }

    // postfix increment/decrement
    constexpr ModInt operator++(int) noexcept {
        ModInt tmp(*this);
        ++*this;
        return tmp;
    }
    constexpr ModInt operator--(int) noexcept {
        ModInt tmp(*this);
        --*this;
        return tmp;
    }

    constexpr ModInt operator+(const ModInt& rhs) const noexcept {
        return ModInt(*this) += rhs;
    }
    constexpr ModInt operator-(const ModInt& rhs) const noexcept {
        return ModInt(*this) -= rhs;
    }
    constexpr ModInt operator*(const ModInt& rhs) const noexcept {
        return ModInt(*this) *= rhs;
    }
    constexpr ModInt operator/(const ModInt& rhs) const noexcept {
        return ModInt(*this) /= rhs;
    }

    constexpr ModInt& operator+=(const ModInt& rhs) noexcept {
        val += rhs.val;
        if (val >= MOD) val -= MOD;
        return *this;
    }
    constexpr ModInt& operator-=(const ModInt& rhs) noexcept {
        if (val < rhs.val) val += MOD;
        val -= rhs.val;
        return *this;
    }
    constexpr ModInt& operator*=(const ModInt& rhs) noexcept {
        val = val * rhs.val % MOD;
        return *this;
    }

    // prime Modulus only
    constexpr ModInt& operator/=(const ModInt& rhs) noexcept {
        return *this *= rhs.inv();
    }

    // prime Modulus only
    constexpr ModInt inv() const noexcept {
        return pow(*this, MOD - 2);
    }
};

template<std::uint_fast64_t Modulus>
constexpr ModInt<Modulus> pow(ModInt<Modulus> x, std::uint_fast64_t n) {
    ModInt<Modulus> res(1);
    while (n) {
        if (n & 1) res *= x;
        x *= x;
        n >>= 1;
    }
    return res;
}

template<std::uint_fast64_t Modulus>
istream& operator>>(istream& is, ModInt<Modulus>& x) {
    std::uint_fast64_t val;
    is >> val;
    x = ModInt<Modulus>(val);
    return is;
}

template<std::uint_fast64_t Modulus>
ostream& operator<<(ostream& os, const ModInt<Modulus>& x) {
    return os << x.val;
}

using mint = ModInt<1000000007>;

using Poly = vector<mint>;

// return p(x) q(-x)
inline Poly mul(const Poly& p, const Poly& q) noexcept {
    int sz_p = p.size(), sz_q = q.size();
    Poly res(sz_p + sz_q - 1, 0);

    for (int i = 0; i < sz_p; i++) {
        for (int j = 0; j < sz_q; j++) {
            res[i + j] += p[i] * q[j];
        }
    }
    return res;
}

inline Poly even(const Poly& p) noexcept {
    int sz = p.size();
    Poly res((sz + 1) / 2, 0);

    for (int i = 0; i < sz; i += 2) {
        res[i >> 1] = p[i];
    }
    return res;
}

inline Poly odd(const Poly& p) noexcept {
    int sz = p.size();
    Poly res(sz / 2, 0);

    for (int i = 1; i < sz; i += 2) {
        res[(i - 1) >> 1] = p[i];
    }
    return res;
}

// return p(x) q(-x)
inline Poly mul_pn(const Poly& p, const Poly& q) noexcept {
    int sz_p = p.size(), sz_q = q.size();
    Poly res(sz_p + sz_q - 1, 0);

    for (int i = 0; i < sz_p; i++) {
        for (int j = 0; j < sz_q; j++) {
            res[i + j] += p[i] * ((j & 1) ? -q[j] : q[j]);
        }
    }
    return res;
}

// http://q.c.titech.ac.jp/docs/progs/polynomial_division.html
mint calc(Poly p, Poly q, ll n) {
    while (n > 0) {
        if (n & 1) p = odd(mul_pn(p, q));
        else p = even(mul_pn(p, q));

        q = even(mul_pn(q, q));
        n >>= 1;
    }
    return p[0];
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);

    const Poly f1 = {1, mint::MOD - 1};
    const Poly f2 = {1, 1};

    Poly p = {0, 0, 0, 0, 0, 1};
    Poly q = f1;

    for (int i = 0; i < 15; i++) {
        q = mul(q, f1);
    }

    for (int i = 0; i < 5; i++) {
        q = mul(q, f2);
    }

    int t;
    cin >> t;

    for (int i = 0; i < t; i++) {
        ll n;
        cin >> n;
        cout << calc(p, q, n) << newl;
    }
    return 0;
}

Measured memory_bytes: 3620