#include "atcoder/fenwicktree.hpp" #include #include using namespace std; using isize = size_t; using i32 = int; using u32 = unsigned int; using i64 = long long; using u64 = unsigned long long; using i128 = __int128_t; using u128 = __uint128_t; using f64 = long double; using p2 = pair; using el = tuple; using mint = atcoder::modint998244353; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); } i64 pow(i64 x, i64 n) { i64 res = 1; i64 t = x; while (n > 0) { if (n & 1) { res = res * t; } t = t * t; n >>= 1; } return res; } i64 pow(i64 x, i64 n, i64 m) { i64 res = 1; i64 t = x % m; while (n > 0) { if (n & 1) { res = res * t % m; } t = t * t % m; n >>= 1; } return res; } vector> mul(vector> &a, vector> &b) { vector> res(a.size(), vector(b[0].size(), 0)); assert(a[0].size() == b.size()); for (i64 i = 0; i < a.size(); i++) { for (i64 j = 0; j < b[0].size(); j++) { for (i64 k = 0; k < b.size(); k++) { res[i][j] += a[i][k] * b[k][j]; } } } return res; } vector> pow(vector> &a, i64 n) { assert(a.size() == a[0].size()); vector> res(a.size(), vector(a[0].size(), 0)); vector> t = a; for (i64 i = 0; i < a.size(); i++) res[i][i] = 1; while (n > 0) { if (n & 1) { vector> nres = mul(res, t); swap(res, nres); } vector> nt = mul(t, t); swap(nt, t); n >>= 1; } return res; } void _main() { i64 ttt; cin >> ttt; for (;ttt--;) { i64 n; cin >> n; vector> a(8, vector(8, 0)); for (i64 i = 0; i < 8; i++) { if (i == 3) { continue; } if (i == 7) { a[7][0] = a[7][7] = 1; continue; } for (i64 j = 0; j < 8; j++) { if ((i % 4) == (j % 4) || (i % 4) + 1 == (j % 4)) { if (j == 3) { a[i][0]++; } else { a[i][j]++; } } } } a = pow(a, n); // for (i64 i = 0; i < 8; i++) { // for (i64 j = 0; j < 8; j++) { // cout << a[i][j].val() << " "; // } // cout << "\n"; // } cout << (a[0][0] - mint(2).pow(n - 1)).val() << "\n"; } }