//#include #include "bits/stdc++.h" using namespace std; typedef long long ll; /* #include "boost/multiprecision/cpp_int.hpp" #include "boost/multiprecision/cpp_dec_float.hpp" namespace mp = boost::multiprecision; typedef mp::cpp_int LL; typedef mp::number> DD;// 仮数部が1024ビットの浮動小数点数型(TLEしたら小さくする) */ typedef long double dd; //#define i_7 (ll)(1E9+7) #define i_7 998244353 #define i_5 i_7-2 ll mod(ll a){ ll c=a%i_7; if(c>=0)return c; return c+i_7; } typedef pair l_l; typedef pair d_d; ll inf=(ll)1E16; #define rep(i,l,r) for(ll i=l;i<=r;i++) #define pb push_back ll max(ll a,ll b){if(ab)return b;else return a;} void Max(ll &pos,ll val){pos=max(pos,val);}//Max(dp[n],dp[n-1]); void Min(ll &pos,ll val){pos=min(pos,val);} void Add(ll &pos,ll val){pos=mod(pos+val);} dd EPS=1E-9; #define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0); #define fi first #define se second #define endl "\n" #define SORT(v) sort(v.begin(),v.end()) #define ERASE(v) v.erase(unique(v.begin(),v.end()),v.end()) #define POSL(v,x) (lower_bound(v.begin(),v.end(),x)-v.begin()) #define POSU(v,x) (upper_bound(v.begin(),v.end(),x)-v.begin()) template inline bool chmax(T &a, T b) { if(a < b) { a = b; return true; } return false; } template inline bool chmin(T &a, T b) { if(a > b) { a = b; return true; } return false; } void mod_print(ll k){ ll P=1000; rep(y,1,P){ ll x=mod(y*k); if(x+P>=i_7){ x-=i_7; } if(abs(x)<=P){ cout< tmp; size_t sz = 1; inline int powMod(int n, int p, int m) { int res = 1; while (p) { if (p & 1) res = (ll)res * n % m; n = (ll)n * n % m; p >>= 1; } return (int)res; } inline int invMod(int n, int m) { return powMod(n, m - 2, m); } template struct NTTPart { static std::vector ntt(std::vector a, bool inv = false) { size_t mask = sz - 1; size_t p = 0; for (size_t i = sz >> 1; i >= 1; i >>= 1) { auto& cur = (p & 1) ? tmp : a; auto& nex = (p & 1) ? a : tmp; int e = powMod(PrimitiveRoot, (Mod - 1) / sz * i, Mod); if (inv) e = invMod(e, Mod); int w = 1; for (size_t j = 0; j < sz; j += i) { for (size_t k = 0; k < i; ++k) { nex[j + k] = (cur[((j << 1) & mask) + k] + (ll)w * cur[(((j << 1) + i) & mask) + k]) % Mod; } w = (ll)w * e % Mod; } ++p; } if (p & 1) std::swap(a, tmp); if (inv) { int invSz = invMod(sz, Mod); for (size_t i = 0; i < sz; ++i) a[i] = (ll)a[i] * invSz % Mod; } return a; } static std::vector mul(std::vector a, std::vector b) { a = ntt(a); b = ntt(b); for (size_t i = 0; i < sz; ++i) a[i] = (ll)a[i] * b[i] % Mod; a = ntt(a, true); return a; } }; constexpr int M[] = { 1224736769, 469762049, 167772161 }; constexpr int PR[] = { 3, 3, 3 }; constexpr int NTT_CONVOLUTION_TIME = 1; inline void garner(std::vector *c, int mod) { if (NTT_CONVOLUTION_TIME == 1) { for (auto& x : c[0]) x %= mod; } else if (NTT_CONVOLUTION_TIME == 2) { const int r01 = invMod(M[0], M[1]); for (size_t i = 0; i < sz; ++i) { c[1][i] = (c[1][i] - c[0][i]) * (ll)r01 % M[1]; if (c[1][i] < 0) c[1][i] += M[1]; c[0][i] = (c[0][i] + (ll)c[1][i] * M[0]) % mod; } } else if (NTT_CONVOLUTION_TIME == 1) { const int R01 = invMod(M[0], M[1]); const int R02 = invMod(M[0], M[2]); const int R12 = invMod(M[1], M[2]); const int M01 = (ll)M[0] * M[1] % mod; for (size_t i = 0; i < sz; ++i) { c[1][i] = (c[1][i] - c[0][i]) * (ll)R01 % M[1]; if (c[1][i] < 0) c[1][i] += M[1]; c[2][i] = ((c[2][i] - c[0][i]) * (ll)R02 % M[2] - c[1][i]) * R12 % M[2]; if (c[2][i] < 0) c[2][i] += M[2]; c[0][i] = (c[0][i] + (ll)c[1][i] * M[0] + (ll)c[2][i] * M01) % mod; } } } std::vector mul(std::vector a, std::vector b, int mod) { for (auto& x : a) x %= mod; for (auto& x : b) x %= mod; size_t m = a.size() + b.size() - 1; sz = 1; while (m > sz) sz <<= 1; tmp.resize(sz); a.resize(sz, 0); b.resize(sz, 0); std::vector c[NTT_CONVOLUTION_TIME]; if (NTT_CONVOLUTION_TIME >= 1) c[0] = NTTPart::mul(a, b); if (NTT_CONVOLUTION_TIME >= 2) c[1] = NTTPart::mul(a, b); if (NTT_CONVOLUTION_TIME >= 3) c[2] = NTTPart::mul(a, b); for (auto& v : c) v.resize(m); garner(c, mod); return c[0]; } }; int SOLVE(){ /*a.pb(1);a.pb(2); b.pb(1);b.pb(4); auto c(NTT::mul(a, b, i_7)); for(auto x:c)cout<>n>>q; vectorc;c.pb(1); rep(zx,0,n-1){ vectora(2); a[0]=1;cin>>a[1]; a[1]--; c=NTT::mul(a,c,i_7); } //for(auto x:c)cout<>t; cout<(end - start) / CLOCKS_PER_SEC * 1000.0; cerr<