#include #include using namespace std; using ll = long long; using ul = unsigned long; using ld = long double; using st = string; using mint = atcoder::modint998244353; using Mint = atcoder::modint1000000007; #define vl vector #define vvl vector> #define vvvl vector>> #define vvvvl vector>>> #define vd vector #define vvd vector> #define vvvd vector>> #define vb vector #define vvb vector> #define vvvb vector>> #define vs vector #define vvs vector> #define vvvs vector>> #define vp vector> #define vvp vector>> #define vvvp vector>>> #define vm vector #define vvm vector> #define vM vector #define vvM vector> #define cmx(n,v) n=nv?v:n #define all(n) begin(n),end(n) #define nxp(a) next_permutation(all(a)) #define rev(n) reverse(all(n)) #define sor(n) stable_sort(all(n)) #define rep(i,n) for(ll i=0;i<(n);++i) #define reprev(i,n) for(ll i=n-1;0<=i;--i) #define rrep(i,a,n) for(ll i=a;i<(n);++i) #define sz(n) n.size() #define bit(j,i) (i&(1<0){ res++; N/=10; } return res; } ll factorial(ll n, ll mod = 1e18) { ll ans = 1; for(ll i = n; i >= 2; i--) ans = (ans * i) % mod; return ans; } ll round_up(ll x,ll y){ return (x+y-1)/y; } ll floor_int(ll x,ll m){ ll r=(x%m+m)%m; //負の剰余を正の剰余に置き換える return (x-r)/m; //return } ll rmd(ll x,ll m){ ll r=(x%m+m)%m; //負の剰余を正の剰余に置き換える return r; } ll rmd_2(ll x,ll m){ ll r=(x%m+m)%m; //負の剰余を正の剰余に置き換える return (m-r)%m; //return } ll bubble_sort(vl a,ll n){ ll res=0; rep(i,n-1){ for(ll j=n-1;j>i;j--){ if(a[j-1]>a[j]){ swap(a[j-1],a[j]); res++; } } } return res; } ll sum_v(vl a){ ll res=0; ll n=sz(a); rep(i,n) res+=a[i]; return res; } ll stair_sum(ll from,ll to){ return (from+to)*(to-from+1)/2; } ll Power(ll var, ll p) { if (p == 1) return var; ll ans = Power(var * var, p / 2); if (p & 1) ans *= var;; return ans; } ll cnt_01(ll n,ll now){ ll res=0; res+=(n/now)*(now/2); if(n%now>=now/2) res+=n%now-(now/2)+1; return res; } ll sum_pop(ll n){ ll res=0; for(ll b=0;b<60;b++){ res+=(n/(1ll<<(b+1)))*(1ll< q; q.push(start); vl dis(n,inf); dis[start]=0; while(!q.empty()){ ll u=q.front(); q.pop(); start=u; ans=dis[u]; for(ll v:g[u]){ if(dis[v]!=inf) continue; dis[v]=dis[u]+1; q.push(v); } } } return ans; } mint m_Power(mint var,ll p) { if (p == 1) return var; mint ans = m_Power(var * var, p / 2); if (p & 1) ans *= var;; return ans; } Mint M_Power(Mint var,ll p) { if (p == 1) return var; Mint ans = M_Power(var * var, p / 2); if (p & 1) ans *= var;; return ans; } bool is_prime(ll N){ if(N==1) return false; if(N==2) return true; if(N%2==0) return false; for(ll p=3;p*p<=N;p+=2) if(N%p==0) return false; return true; } bool in_out(ll x,ll y,ll h,ll w){ return 0<=x and xn||p>res[d]) break; res[p*d]=p; } } return res; } vvl to_grid(vl &a,ll k){ ll n=sz(a); ll m=(n+k-1)/k; vvl b(k,vl(m,inf)); rep(i,n) b[i%k][i/k]=a[i]; return b; } vvl rotate_ll(vvl& V2d,ll wise){ vvl a=V2d; ll h=sz(a),w=sz(a[0]); vvl res(w,vl(h)); if(wise) {rep(i,h)rep(j,w) res[j][h-i-1]=a[i][j];} else {rep(i,h)rep(j,w) res[w-j-1][i]=a[i][j];} return res; } vs rotate_st(vs s,ll wise){ vs a=s; ll h=sz(a),w=sz(a[0]); vs res(w); rep(i,w) res[i].append(h,'.'); if(wise) {rep(i,h)rep(j,w) res[j][h-i-1]=a[i][j];} else {rep(i,h)rep(j,w) res[w-j-1][i]=a[i][j];} return res; } vp prime_factorize(ll N){ vp res; for (ll a = 2; a * a <= N; ++a) { if (N % a != 0) continue; ll ex = 0; while (N % a == 0) { ex++; N /= a; } res.push_back({a, ex}); } if (N != 1) res.push_back({N, 1}); return res; } template void input(T &a) { cin >> a; }; template void input(T1&a, T2 &...b) { cin >> a; input(b...); }; template vector rd(size_t n) { vector ts(n); for (size_t i = 0; i < n; i++) cin >> ts[i]; return ts; } template void read_tuple_impl(TV&) {} template void read_tuple_impl(TV& ts) { get(ts).emplace_back(*(istream_iterator(cin))); read_tuple_impl(ts); } template decltype(auto) read_tuple(size_t n) { tuple...> ts; for (size_t i = 0; i < n; i++) read_tuple_impl(ts); return ts; } ll di[8]={1,-1,0,0,1,1,-1,-1}; ll dj[8]={0,0,1,-1,1,-1,-1,1}; //abcdefghijklmnopqrstuvwxyz //std::setprecision(15); //2^29<10^9 struct fibo{ vector> dp; fibo(ll x){ dp.push_back({1,1,1,0}); rep(i,60){ auto[a,b,c,d]=dp[i]; dp.push_back({a*a+b*c,a*b+b*d,c*a+d*c,c*b+d*d}); } } mint calc(ll n){ array res={1,1}; rep(i,60){ if(!((n>>i)&1ll)) continue; auto[a,b,c,d]=dp[i]; array nres; nres[0]=a*res[0]+b*res[1]; nres[1]=c*res[0]+d*res[1]; res=nres; } return res[0]; } }; struct luca{ vector> dp; luca(ll x){ dp.push_back({1,1,1,0}); rep(i,60){ auto[a,b,c,d]=dp[i]; dp.push_back({a*a+b*c,a*b+b*d,c*a+d*c,c*b+d*d}); } } mint calc(ll n){ array res={3,1}; rep(i,60){ if(!((n>>i)&1ll)) continue; auto[a,b,c,d]=dp[i]; array nres; nres[0]=a*res[0]+b*res[1]; nres[1]=c*res[0]+d*res[1]; res=nres; } return res[0]; } }; int main(){ ios::sync_with_stdio(0); cin.tie(0); ll q; cin >> q; fibo f(5); luca l(5); while(q--){ ll n; cin >> n; mint ans=0; ans+=mint(5)*(f.calc(n))*(f.calc(n)); ans-=(l.calc(n))*(l.calc(n)); cout << ans.val() << endl; } return 0; }