#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <deque>
#include <complex>
#include <stack>
#include <queue>
#include <cstdio>
#include <cctype>
#include <cstring>
#include <ctime>
#include <iterator>
#include <bitset>
#include <numeric>
#include <list>
#include <iomanip>
#include <cassert>

#if __cplusplus >= 201103L
#include <array>
#include <tuple>
#include <initializer_list>
#include <unordered_set>
#include <unordered_map>
#include <forward_list>

using namespace std;

#define cauto const auto&
#define ALL(v) begin(v),end(v)
#else
#define ALL(v) (v).begin(),(v).end()
#endif

namespace{
typedef long long LL;
typedef pair<int,int> pii;
typedef pair<LL,LL> pll;

typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;

#define VV(T) vector<vector< T > >

template <class T>
void initvv(vector<vector<T> > &v, int a, int b, const T &t = T()){
	v.assign(a, vector<T>(b, t));
}
template <class T> inline T &chmin(T &x, const T &y){ return x = min(x, y); }
template <class T> inline T &chmax(T &x, const T &y){ return x = max(x, y); }
template <class F, class T>
void convert(const F &f, T &t){
	stringstream ss;
	ss << f;
	ss >> t;
}
template <class Con>
string concat(const Con &c, const string &spr){
	stringstream ss;
	typename Con::const_iterator it = c.begin(), en = c.end();
	bool fst = true;
	for(; it != en; ++it){
		if(!fst){ ss << spr; }
		fst = false;
		ss << *it;
	}
	return ss.str();
}

template <class Con, class Fun>
vector<typename Con::value_type> cfilter(const Con &c, Fun f) {
	vector<typename Con::value_type> ret;
	typename Con::const_iterator it = c.begin(), en = c.end();
	for(; it != en; ++it){
		if(f(*it)){
			ret.emplace_back(*it);
		}
	}
	return ret;
}
#if __cplusplus >= 201103L
template <class Con, class Fun>
auto cmap(const Con &c, Fun f) -> vector<decltype(f(*c.begin()))> {
	vector<decltype(f(*c.begin()))> ret;
	ret.reserve(c.size());
	for(const auto &x: c){
		ret.emplace_back(f(x));
	}
	return ret;
}
#endif


#define REP(i,n) for(int i=0;i<int(n);++i)
#define RALL(v) (v).rbegin(),(v).rend()
#define tget(t,i) get<i>(t)

#define MOD 1000000007LL
#define EPS 1e-8

constexpr LL powmod(LL x, LL y){
	LL a = 1;
	while(y){
		if(y & 1){ a = a * x % MOD; }
		x = x * x % MOD;
		y >>= 1;
	}
	return a;
}

constexpr LL inv(LL x){ return powmod(x, MOD - 2); }

LL cmb(LL n, int k){
	LL a = 1, b = 1;
	for(int i = 1; i <= k; ++i){
		a = a * (n - i + 1) % MOD;
		b = b * i % MOD;
	}
	return a * inv(b) % MOD;
}

LL expand(LL n, int k){
	LL a = cmb(n + k - 1, k - 1);
cerr<<n<<", "<<k<<": "<<a<<endl;
	return a;
}

void calc(LL &ans, LL n, bool neg, int a, int b, int k){
	LL t = expand(n, k) * a % MOD * inv(b) % MOD;
	if(!neg && n % 2){ t = MOD - t; }
	ans += t;
}

LL solve(){
	LL n;
	scanf("%lld", &n);

	if(n <= 4){ return 0; }
	n -= 5;
	LL ans = 0;
	
	calc(ans, n, false, 969, 262144, 1);
	calc(ans, n, false, 51, 32768, 2);
	calc(ans, n, false, 17, 32768, 3);
	calc(ans, n, false, 1, 8192, 4);
	calc(ans, n, false, 1, 65536, 5);
	calc(ans, n, true, 969, 262144, 1);
	calc(ans, n, true, 765, 131072, 2);
	calc(ans, n, true, 595, 65536, 3);
	calc(ans, n, true, 455, 32768, 4);
	calc(ans, n, true, 1365, 65536, 5);
	calc(ans, n, true, 1001, 32768, 6);
	calc(ans, n, true, 715, 16384, 7);
	calc(ans, n, true, 495, 8192, 8);
	calc(ans, n, true, 165, 2048, 9);
	calc(ans, n, true, 105, 1024, 10);
	calc(ans, n, true, 63, 512, 11);
	calc(ans, n, true, 35, 256, 12);
	calc(ans, n, true, 35, 256, 13);
	calc(ans, n, true, 15, 128, 14);
	calc(ans, n, true, 5, 64, 15);
	calc(ans, n, true, 1, 32, 16);

	ans = (ans % MOD + MOD) % MOD;
	
	return ans;
}

void mainmain(){
	int t;
	scanf("%d", &t);
	for(int i = 0; i < t; ++i){
		LL ans = solve();
		printf("%lld\n", ans);
	}
}



}
int main() try{
//	ios::sync_with_stdio(false); cin.tie(0);
	cout << fixed << setprecision(10);
	cerr << fixed << setprecision(4);
	mainmain();
}
catch(const exception &e){
	cerr << "exception: " << e.what() << endl;
	abort();
}
catch(...){
	cerr << "exception" << endl;
	abort();
}


Measured memory_bytes: 3788