#include using namespace std; using uint=unsigned; using ll=long long; using ull=unsigned long long; #define int ll #define FOR(i,a,b) for(int i=int(a);i=a;i--) #define per(i,b) ROF(i,0,b) #define mp make_pair #define mt make_tuple #define pb push_back #define eb emplace_back #define all(x) x.begin(),x.end() auto& errStream=cerr; #ifdef LOCAL #define cerr (cerr<<"-- line "<<__LINE__<<" -- ") #else class CerrDummy{}cerrDummy; template CerrDummy& operator<<(CerrDummy&cd,const T&){ return cd; } using charTDummy=char; using traitsDummy=char_traits; CerrDummy& operator<<(CerrDummy&cd,basic_ostream&(basic_ostream&)){ return cd; } #define cerr cerrDummy #endif #define reach cerr<<"reached"< void dmpr(decltype(cerr)&os,const T&t,const Args&... args){ os< using V=vector; template using VV=V>; using pi=pair; using vi=vector; using ld=long double; template ostream& operator<<(ostream& os,const pair& p){ os<<"("< ostream& operator <<(ostream& os,const vector& v){ os<<"{"; rep(i,(int)v.size()){ if(i)os<<","; os< void print_tuple(ostream&,const T&){ } template void print_tuple(ostream&os,const T&t){ if(i)os<<","; os<(t); print_tuple(os,t); } template ostream& operator<<(ostream&os,const tuple&t){ os<<"("; print_tuple<0,tuple,Args...>(os,t); return os<<")"; } ll read(){ ll i; scanf("%lld",&i); return i; } void printSpace(){ printf(" "); } void printEoln(){ printf("\n"); } void print(ll x,int suc=1){ printf("%lld",x); if(suc==1) printEoln(); if(suc==2) printSpace(); } vi readvi(int n,int off=0){ vi v(n); rep(i,n)v[i]=read()+off; return v; } template void print(const vector&v,int suc=1){ rep(i,v.size()) print(v[i],i==int(v.size())-1?suc:2); } string readString(){ static char buf[3341000]; scanf("%s",buf); return string(buf); } char* readCharArray(){ static char buf[3341000]; static int bufUsed=0; char* ret=buf+bufUsed; scanf("%s",ret); bufUsed+=strlen(ret)+1; return ret; } template void chmax(T& a,U b){ if(a void chmin(T& a,U b){ if(b T Sq(const T& t){ return t*t; } //#define CAPITAL void Yes(bool ex=true){ #ifdef CAPITAL cout<<"YES"< vector uni(const vector&vv){ auto v(vv); sort(all(v)); v.erase(unique(all(v)),v.end()); return v; } template void mkuni(vector&v){ sort(all(v)); v.erase(unique(all(v)),v.end()); } //ayasii int topbit(signed t){ return t==0?-1:31-__builtin_clz(t); } int topbit(ll t){ return t==0?-1:63-__builtin_clzll(t); } int popcount(signed t){ return __builtin_popcount(t); } int popcount(ll t){ return __builtin_popcountll(t); } bool ispow2(int i){ return i&&(i&-i)==i; } bool inc(int a,int b,int c){ return a<=b&&b<=c; } #define SMOD #ifdef SMOD template #else uint mod; #endif struct ModInt{ #ifdef SMOD static constexpr uint base=mod; #else static constexpr uint& base=mod; #endif uint v; ModInt():v(0){} ModInt(ll vv){ s(vv%mod+mod); } ModInt& s(uint vv){ v=vv>=1; } return res; } ModInt inv()const{ return pow(mod-2); } }; #ifdef SMOD template ostream& operator<<(ostream&os,const ModInt&m){ return os< void print(const ModInt&m,int suc=1){ print(m.v,suc); } #else ostream& operator<<(ostream&os,const ModInt&m){ return os<; //using mint=ModInt<998244353>; #else using mint=ModInt; #endif const int Vmax=(1<<21)+10; mint fact[Vmax],factInv[Vmax],invs[Vmax]; void InitFact(){ fact[0]=1; FOR(i,1,Vmax){ fact[i]=fact[i-1]*i; } factInv[Vmax-1]=fact[Vmax-1].inv(); for(int i=Vmax-2;i>=0;i--){ factInv[i]=factInv[i+1]*(i+1); } for(int i=Vmax-1;i>=1;i--){ invs[i]=factInv[i]*fact[i-1]; } } #ifdef SMOD struct InitFactDummy{ InitFactDummy(){ InitFact(); } } initFactDummy; #endif mint Choose(int n,int k){ return fact[n]*factInv[n-k]*factInv[k]; } mint Binom(int a,int b){ return fact[a+b]*factInv[a]*factInv[b]; } mint Catalan(int n){ return Binom(n,n)-(n-1>=0?Binom(n-1,n+1):0); } //res: k by d table //for all n sum_{0<=i p_recursive(const V&a,int d){ int n=a.size(); int k=(n+2)/(d+1); int m=k*d; VV x(m,V(m+m-1)); rep(p,m-1)rep(i,k){ mint w=a[p+i]; rep(j,d){ x[i*d+j][p]=w; w*=(p+i); } } rep(i,m) x[i][m-1+i]=1; V v; rep(i,m){ int j=0; while(j res=VV(int(v.size()+d-1)/d,V(d)); rep(i,v.size()) res[i/d][i%d]=v[i]; return res; } V extend_sequence(const V&a,const VV& f,int n){ int k=f.size(),d=f[0].size(); assert(int(a.size())>=k-1); V res(n),w(k); rep(i,n){ if(i calc(int n){ V res(n+1); res[1]=1; dp[2][0][0][0]=2; FOR(i,2,n+1){ res[i]=dp[i][0][0][0]; rep(j,i){ rep(p,2)rep(q,2){ mint a=p==0?j:j-1; mint b=p==0?2:1; mint c=p==0?0:1; mint d=i+1-a-b-c; if(j){ if(q==0){ dp[i+1][j-1][q][0]+=dp[i][j][p][q]*a; }else{ dp[i+1][j-1][q][0]+=dp[i][j][p][q]*(a-1); dp[i+1][j-1][0][0]+=dp[i][j][p][q]; } } dp[i+1][j+1][q][1]+=dp[i][j][p][q]*b; dp[i+1][j][q][1]+=dp[i][j][p][q]*c; dp[i+1][j][q][0]+=dp[i][j][p][q]*d; } } } return res; } signed main(){ auto a=calc(100); a.erase(a.bg); auto f=p_recursive(a,5); errStream<