#include #if __has_include() #include #endif using namespace std; #define LL(...) ll __VA_ARGS__;lin(__VA_ARGS__) #define FO(n) for(ll IJK=n;IJK-->0;) #define fo(i,...) for(auto[i,i##stop,i##step]=for_range(0,__VA_ARGS__);ivoid pp(const auto&...a){[[maybe_unused]]const char*c="";((o<(a...);} #define entry defpp void main();void main2();}int main(){my::io();my::main();}namespace my{ #define multiple_testcases LL(T);FO(T)main2();}void main2(){ #define use_ml998244353 using ml=atcoder::modint998244353; namespace my{ auto&operator<<(ostream&o,const atcoder::modint998244353&x){return o<<(int)x.val();} void io(){cin.tie(nullptr)->sync_with_stdio(0);cout<constexpr auto for_range(T s,T b){T a=0;if(s)swap(a,b);return array{a-s,b,1-s*2};} void lin(auto&...a){(cin>>...>>a);} constexpr auto pow(auto x,ll n,auto e){assert(n>=0);decltype(x)r=e;for(;n;x*=x,n>>=1)if(n&1)r*=x;return r;} templateusing pack_back_t=tuple_element_t>; } namespace my{ templatestruct vec; templatestruct hvec_helper{using type=vec::type>;}; templatestruct hvec_helper<0,T>{using type=T;}; templateusing hvec=hvec_helper::type; templatestruct vec:vector{ using vector::vector; ll size()const{return vector::size();} }; templaterequires(sizeof...(A)>=2)vec(const A&...a)->vec>>; } namespace my{ templatestruct matrix:vec>{ ll H,W; matrix()=default; matrix(ll n):H(n),W(n){this->resize(n,vec(n));} matrix(ll n,ll m,T x={}):H(n),W(m){this->resize(n,vec(m,x));} matrix(const vec>&v):H(v.size()),W(v[0].size()){vector>::operator=(v);} auto&operator*=(const matrix&a){ assert(W==a.H); matrix r(H,a.W); fo(i,H)fo(k,W)fo(j,a.W)r[i][j]+=(*this)[i][k]*a[k][j]; swap(*this,r); return*this; } friend vecoperator*(const vec&v,const matrix&a){ assert(v.size()==a.H); vecr(a.W); fo(i,a.H)fo(j,a.W)r[j]+=v[i]*a[i][j]; return r; } auto pow(ll n)const{matrix e(H);fo(i,H)e[i][i]=1;return my::pow(*this,n,e);} auto transpose()const{ matrix r(W,H); fo(i,H)fo(j,W)r[j][i]=(*this)[i][j]; return r; } }; } namespace my{entry void main(){ multiple_testcases LL(N); use_ml998244353 // 総乗が8になったら1にリセットする. matrixA{{ {1,1,0,0,0,0,0}, // -1 {1,1,0,0,1,1,1}, // 1 {1,1,1,1,0,0,0}, // -2 {1,1,1,1,0,0,0}, // 2 {0,0,1,1,1,1,0}, // -4 {0,0,1,1,1,1,0}, // 4 {0,0,0,0,1,1,1}, // -8 }}; A=A.pow(N); // 一度も8になることなく1になる場合を取り除く. // そのような列は-1が偶数個と残りが全て1で作られる列で,その個数は // c(N,0)+c(N,2)+...+c(N,2[N/2])=2^{N-1} pp((vec{0,1,0,0,0,0,0}*A.transpose())[1]-ml(2).pow(N-1)); }}