#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef int ll;
typedef long double ld;
const ll N = 200005;
char en = '\n';
ll inf = 1e16;
ll mod = 1e9 + 7;
ll power(ll x, ll n, ll mod) {
  ll res = 1;
  x %= mod;
  while (n) {
    if (n & 1)
      res = (res * x) % mod;
    x = (x * x) % mod;
    n >>= 1;
  }
  return res;
}

constexpr int md = (int)1e9 + 7;

// make it understandable one day...
namespace fft {
typedef double dbl;

struct num {
  dbl x, y;
  num() { x = y = 0; }
  num(dbl x_, dbl y_) : x(x_), y(y_) {}
};

inline num operator+(num a, num b) { return num(a.x + b.x, a.y + b.y); }
inline num operator-(num a, num b) { return num(a.x - b.x, a.y - b.y); }
inline num operator*(num a, num b) {
  return num(a.x * b.x - a.y * b.y, a.x * b.y + a.y * b.x);
}
inline num conj(num a) { return num(a.x, -a.y); }

int base = 1;
vector<num> roots = {{0, 0}, {1, 0}};
vector<int> rev = {0, 1};

const dbl PI = static_cast<dbl>(acosl(-1.0));

void ensure_base(int nbase) {
  if (nbase <= base) {
    return;
  }
  rev.resize(1 << nbase);
  for (int i = 0; i < (1 << nbase); i++) {
    rev[i] = (rev[i >> 1] >> 1) + ((i & 1) << (nbase - 1));
  }
  roots.resize(1 << nbase);
  while (base < nbase) {
    dbl angle = 2 * PI / (1 << (base + 1));
    //      num z(cos(angle), sin(angle));
    for (int i = 1 << (base - 1); i < (1 << base); i++) {
      roots[i << 1] = roots[i];
      //        roots[(i << 1) + 1] = roots[i] * z;
      dbl angle_i = angle * (2 * i + 1 - (1 << base));
      roots[(i << 1) + 1] = num(cos(angle_i), sin(angle_i));
    }
    base++;
  }
}

void fft(vector<num> &a, int n = -1) {
  if (n == -1) {
    n = (int)a.size();
  }
  assert((n & (n - 1)) == 0);
  int zeros = __builtin_ctz(n);
  ensure_base(zeros);
  int shift = base - zeros;
  for (int i = 0; i < n; i++) {
    if (i < (rev[i] >> shift)) {
      swap(a[i], a[rev[i] >> shift]);
    }
  }
  for (int k = 1; k < n; k <<= 1) {
    for (int i = 0; i < n; i += 2 * k) {
      for (int j = 0; j < k; j++) {
        num z = a[i + j + k] * roots[j + k];
        a[i + j + k] = a[i + j] - z;
        a[i + j] = a[i + j] + z;
      }
    }
  }
}

vector<num> fa, fb;

vector<int64_t> square(const vector<int> &a) {
  if (a.empty()) {
    return {};
  }
  int need = (int)a.size() + (int)a.size() - 1;
  int nbase = 1;
  while ((1 << nbase) < need)
    nbase++;
  ensure_base(nbase);
  int sz = 1 << nbase;
  if ((sz >> 1) > (int)fa.size()) {
    fa.resize(sz >> 1);
  }
  for (int i = 0; i < (sz >> 1); i++) {
    int x = (2 * i < (int)a.size() ? a[2 * i] : 0);
    int y = (2 * i + 1 < (int)a.size() ? a[2 * i + 1] : 0);
    fa[i] = num(x, y);
  }
  fft(fa, sz >> 1);
  num r(1.0 / (sz >> 1), 0.0);
  for (int i = 0; i <= (sz >> 2); i++) {
    int j = ((sz >> 1) - i) & ((sz >> 1) - 1);
    num fe = (fa[i] + conj(fa[j])) * num(0.5, 0);
    num fo = (fa[i] - conj(fa[j])) * num(0, -0.5);
    num aux = fe * fe + fo * fo * roots[(sz >> 1) + i] * roots[(sz >> 1) + i];
    num tmp = fe * fo;
    fa[i] = r * (conj(aux) + num(0, 2) * conj(tmp));
    fa[j] = r * (aux + num(0, 2) * tmp);
  }
  fft(fa, sz >> 1);
  vector<int64_t> res(need);
  for (int i = 0; i < need; i++) {
    res[i] = llround(i % 2 == 0 ? fa[i >> 1].x : fa[i >> 1].y);
  }
  return res;
}

vector<int64_t> multiply(const vector<int> &a, const vector<int> &b) {
  if (a.empty() || b.empty()) {
    return {};
  }
  if (a == b) {
    return square(a);
  }
  int need = (int)a.size() + (int)b.size() - 1;
  int nbase = 1;
  while ((1 << nbase) < need)
    nbase++;
  ensure_base(nbase);
  int sz = 1 << nbase;
  if (sz > (int)fa.size()) {
    fa.resize(sz);
  }
  for (int i = 0; i < sz; i++) {
    int x = (i < (int)a.size() ? a[i] : 0);
    int y = (i < (int)b.size() ? b[i] : 0);
    fa[i] = num(x, y);
  }
  fft(fa, sz);
  num r(0, -0.25 / (sz >> 1));
  for (int i = 0; i <= (sz >> 1); i++) {
    int j = (sz - i) & (sz - 1);
    num z = (fa[j] * fa[j] - conj(fa[i] * fa[i])) * r;
    fa[j] = (fa[i] * fa[i] - conj(fa[j] * fa[j])) * r;
    fa[i] = z;
  }
  for (int i = 0; i < (sz >> 1); i++) {
    num A0 = (fa[i] + fa[i + (sz >> 1)]) * num(0.5, 0);
    num A1 = (fa[i] - fa[i + (sz >> 1)]) * num(0.5, 0) * roots[(sz >> 1) + i];
    fa[i] = A0 + A1 * num(0, 1);
  }
  fft(fa, sz >> 1);
  vector<int64_t> res(need);
  for (int i = 0; i < need; i++) {
    res[i] = llround(i % 2 == 0 ? fa[i >> 1].x : fa[i >> 1].y);
  }
  return res;
}

vector<int> multiply_mod(const vector<int> &a, const vector<int> &b, int m) {
  if (a.empty() || b.empty()) {
    return {};
  }
  int eq = (a.size() == b.size() && a == b);
  int need = (int)a.size() + (int)b.size() - 1;
  int nbase = 0;
  while ((1 << nbase) < need)
    nbase++;
  ensure_base(nbase);
  int sz = 1 << nbase;
  if (sz > (int)fa.size()) {
    fa.resize(sz);
  }
  for (int i = 0; i < (int)a.size(); i++) {
    int x = (a[i] % m + m) % m;
    fa[i] = num(x & ((1 << 15) - 1), x >> 15);
  }
  fill(fa.begin() + a.size(), fa.begin() + sz, num{0, 0});
  fft(fa, sz);
  if (sz > (int)fb.size()) {
    fb.resize(sz);
  }
  if (eq) {
    copy(fa.begin(), fa.begin() + sz, fb.begin());
  } else {
    for (int i = 0; i < (int)b.size(); i++) {
      int x = (b[i] % m + m) % m;
      fb[i] = num(x & ((1 << 15) - 1), x >> 15);
    }
    fill(fb.begin() + b.size(), fb.begin() + sz, num{0, 0});
    fft(fb, sz);
  }
  dbl ratio = 0.25 / sz;
  num r2(0, -1);
  num r3(ratio, 0);
  num r4(0, -ratio);
  num r5(0, 1);
  for (int i = 0; i <= (sz >> 1); i++) {
    int j = (sz - i) & (sz - 1);
    num a1 = (fa[i] + conj(fa[j]));
    num a2 = (fa[i] - conj(fa[j])) * r2;
    num b1 = (fb[i] + conj(fb[j])) * r3;
    num b2 = (fb[i] - conj(fb[j])) * r4;
    if (i != j) {
      num c1 = (fa[j] + conj(fa[i]));
      num c2 = (fa[j] - conj(fa[i])) * r2;
      num d1 = (fb[j] + conj(fb[i])) * r3;
      num d2 = (fb[j] - conj(fb[i])) * r4;
      fa[i] = c1 * d1 + c2 * d2 * r5;
      fb[i] = c1 * d2 + c2 * d1;
    }
    fa[j] = a1 * b1 + a2 * b2 * r5;
    fb[j] = a1 * b2 + a2 * b1;
  }
  fft(fa, sz);
  fft(fb, sz);
  vector<int> res(need);
  for (int i = 0; i < need; i++) {
    int64_t aa = llround(fa[i].x);
    int64_t bb = llround(fb[i].x);
    int64_t cc = llround(fa[i].y);
    res[i] = static_cast<int>((aa + ((bb % m) << 15) + ((cc % m) << 30)) % m);
    assert(res[i] >= 0 && res[i] < m);
  }
  return res;
}

} // namespace fft

// sample problem:
// https://www.hackerearth.com/problem/algorithm/something-additive-for-you-4e9342a9/
// sample solution: https://www.hackerearth.com/submission/28854089/

void twice(vector<int> &a) {
  for (ll &x : a) {
    x += x;
    if (x >= md)
      x -= md;
  }
}
void subtract(vector<int> &a, vector<int> b) {
  ll sz = max(a.size(), b.size());
  a.resize(sz);
  b.resize(sz);
  for (ll i = 0; i < sz; i++) {
    a[i] = (a[i] - b[i] + md);
    if (a[i] >= md)
      a[i] -= md;
  }
}

vector<int>
inv(vector<int> arr) { // inverse of size = least power of 2>arr.size()
  ll need = 100;       // change this to get inverse upto desired power of
  // 2(basically degree size-1)
  int nbase = 0;
  while ((1 << nbase) < need)
    nbase++;
  ll sz = (1 << nbase);

  ll curr = 1;
  vector<int> res;
  arr.resize(sz);
  res.resize(curr);
  fill(res.begin(), res.end(), 0);
  res[0] = arr[0];

  while (curr < sz) {
    curr *= 2;
    vector<int> arr2 = fft::multiply_mod(res, res, mod);
    arr2.resize(curr);
    vector<int> arr3;
    copy(arr.begin(), arr.begin() + curr, back_inserter(arr3));
    arr2 = fft::multiply_mod(arr2, arr3, mod);
    arr2.resize(curr);
    twice(res);
    subtract(res, arr2);
    res.resize(curr);
  }
  return res;
}

vector<int> power(vector<int> poly, int n) {
  vector<int> res = {1};
  while (n) {
    if (n & 1)
      res = fft::multiply_mod(res, poly, mod);
    n >>= 1;
    poly = fft::multiply_mod(poly, poly, mod);
  }
  return res;
}

ll MOD = 1e9 + 7;
const ll SZ = 30;
int add(int a, int b) {
  int res = a + b;
  if (res >= MOD)
    return res - MOD;
  return res;
}

int mult(int a, int b) {
  long long res = a;
  res *= b;
  if (res >= MOD)
    return res % MOD;
  return res;
}

struct matrix {
  int arr[SZ][SZ];

  void reset() { memset(arr, 0, sizeof(arr)); }

  void makeiden() {
    reset();
    for (int i = 0; i < SZ; i++) {
      arr[i][i] = 1;
    }
  }

  matrix operator+(const matrix &o) const {
    matrix res;
    for (int i = 0; i < SZ; i++) {
      for (int j = 0; j < SZ; j++) {
        res.arr[i][j] = add(arr[i][j], o.arr[i][j]);
      }
    }
    return res;
  }

  matrix operator*(const matrix &o) const {
    matrix res;
    for (int i = 0; i < SZ; i++) {
      for (int j = 0; j < SZ; j++) {
        res.arr[i][j] = 0;
        for (int k = 0; k < SZ; k++) {
          res.arr[i][j] = add(res.arr[i][j], mult(arr[i][k], o.arr[k][j]));
        }
      }
    }
    return res;
  }
};

matrix power(matrix a, int b) {
  matrix res;
  res.makeiden();
  while (b) {
    if (b & 1) {
      res = res * a;
    }
    a = a * a;
    b >>= 1;
  }
  return res;
}

int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);

  ll t;
  cin >> t;
  while (t--) {
    ll n;
    cin >> n;

    /*
    ll res = 0;
    for (ll s1 = 0; s1 < n; s1++) {
      for (ll s2 = s1 + 1; s2 <= n; s2++) {
        for (ll u1 = 0; u1 < n; u1++) {
          for (ll u2 = u1 + 1; u2 <= n; u2++) {
            for (ll k1 = 0; k1 < n; k1++) {
              for (ll k2 = k1 + 1; k2 <= n; k2++) {
                for (ll e1 = 0; e1 < n; e1++) {
                  for (ll e2 = e1 + 1; e2 <= n; e2++) {

                    for (ll n1 = 0; n1 < n; n1++) {
                      for (ll n2 = n1 + 1; n2 <= n; n2++) {

                        if ((s1 + s2 + u1 + u2 + k1 + k2 + e1 + e2 + n1 + n2) >
    n) continue; res += (s2 - s1) * (u2 - u1) * (k2 - k1) * (e2 - e1) * (n2 -
    n1);
                      }
                    }
                  }
                }
              }
            }
          }
        }
      }
    }
     */

    vector<ll> num(6);
    num[5] = 1;

    vector<ll> den(5);
    den[0] = 1;
    den[1] = (-2 + mod) % mod;
    den[3] = 2;
    den[4] = (-1 + mod) % mod;

    den = power(den, 5);
    /*
      for (ll &x : den)
        cout << x << " ";
      cout << en;*/
    vector<int> init = fft::multiply_mod(num, inv(den), mod);
    /*
      for (ll &x : init)
        cout << x << " ";
      cout << en;*/
    matrix a;
    a.reset();

    den.resize(50);
    for (ll i = 0; i <= 22; i++) {
      a.arr[0][i] = (-den[i + 1] + mod) % mod;
      a.arr[23][i] = (-den[i + 1] + mod) % mod;
    }
    a.arr[23][23] = 1;

    for (ll i = 1; i <= 22; i++) {
      a.arr[i][i - 1] = 1;
    }

    if (n <= 22) {
      ll ans = 0;
      for (ll i = 0; i <= n; i++)
        ans += init[i];
      ans %= mod;
      cout << ans << en;
      continue;
    }

    ll val1 = 0;
    for (ll i = 0; i <= 22; i++) {
      val1 += init[i];
    }
    val1 %= mod;

    a = power(a, n - 22);

    matrix b;
    b.reset();

    for (ll i = 0; i <= 22; i++) {
      b.arr[i][0] = init[22 - i];
    }
    b.arr[23][0] = val1;

    a = a * b;

    cout << a.arr[23][0] << en;
  }
  return 0;
}


Measured memory_bytes: 4080