//by waynetuinforconstint maxn =;constint mod =;constint root =;
template <longlong mod,longlong root>struct NTT {
vector<longlong> omega;NTT(){
omega.resize(maxn +1);longlong x =fpow(root,(mod -1)/ maxn);
omega[0]=1ll;for(int i =1; i <= maxn;++i)
omega[i]= omega[i -1]* x % mod;}longlongfpow(longlong a,longlong n){(n += mod -1)%= mod -1;longlong r =1;for(; n; n >>=1){if(n &1)(r *= a)%= mod;(a *= a)%= mod;}return r;}voidbitrev(vector<longlong>&v,int n){int z =__builtin_ctz(n)-1;for(int i =0; i < n;++i){int x =0;for(int j =0; j <= z;++j) x ^=(i >> j &1)<<(z - j);if(x > i)swap(v[x], v[i]);}}voidntt(vector<longlong>&v,int n){bitrev(v, n);for(int s =2; s <= n; s <<=1){int z = s >>1;for(int i =0; i < n; i += s){for(int k =0; k < z;++k){longlong x = v[i + k + z]* omega[maxn / s * k]% mod;
v[i + k + z]=(v[i + k]+ mod - x)% mod;(v[i + k]+= x)%= mod;}}}}voidintt(vector<longlong>&v,int n){ntt(v, n);for(int i =1; i < n /2;++i)swap(v[i], v[n - i]);longlong inv =fpow(n,-1);for(int i =0; i < n;++i)(v[i]*= inv)%= mod;}
vector<longlong>operator()(vector<longlong> a, vector<longlong> b){int sz =1;while(sz < a.size()+ b.size()-1) sz <<=1;while(a.size()< sz) a.push_back(0);while(b.size()< sz) b.push_back(0);ntt(a, sz),ntt(b, sz);
vector<longlong>c(sz);for(int i =0; i < sz;++i) c[i]= a[i]* b[i]% mod;intt(c, sz);while(c.size()&& c.back()==0) c.pop_back();return c;}};
NTT<mod, root> conv;
vector<longlong>fpow(const vector<longlong>&v,int n){if(n ==1)return v;
vector<longlong> res =fpow(v, n /2);
res =conv(res, res);if(n &1) res =conv(res, v);return res;}