#include using namespace std; #define rep(i,n) REP(i,0,n) #define REP(i,s,e) for(int i=(s); i<(int)(e); i++) #define repr(i, n) REPR(i, n, 0) #define REPR(i, s, e) for(int i=(int)(s-1); i>=(int)(e); i--) #define pb push_back #define all(r) r.begin(),r.end() #define rall(r) r.rbegin(),r.rend() #define fi first #define se second typedef long long ll; typedef vector vi; typedef vector vl; typedef pair pii; typedef pair pll; const int INF = 1e9; const ll MOD = 17; double EPS = 1e-8; template struct Mat { array, SZ> d; const int n; Mat() : n(SZ) { array tmp; tmp.fill(0); d.fill(tmp); } Mat operator * (const Mat& mt) const { Mat ret; rep(i, SZ) rep(j, SZ) { ll sum = 0LL; rep(k, SZ) { (ret.d[i][j] += (d[i][k] * mt.d[k][j]) % MOD) %= MOD; } } return ret; } Mat& operator = (const Mat& mt) { d = mt.d; return *this; } }; template Mat pow(Mat mt, ll n) { Mat ret; rep(i, SZ) ret.d[i][i] = 1LL; while(n > 0) { if(n&1LL) ret = ret * mt; mt = mt*mt; n >>= 1; } return ret; } int main() { int q; cin >> q; Mat<4> mt; rep(i, 4) mt.d[0][i] = 1; rep(i, 3) mt.d[i+1][i] = 1; rep(i, q) { ll n; cin >> n; auto tmp = pow(mt, n); // cout << "n : " << tmp.n << endl; // rep(i, tmp.n) { // rep(j, tmp.n) { // cout << " " << tmp.d[i][j]; // } // cout << endl; // } cout << tmp.d[3][3] << endl; } return 0; }