#include using namespace std; using ll=long long; using ull=unsigned long long; using P=pair; templateusing minque=priority_queue,greater>; templatebool chmax(T &a,const T &b){return (abool chmin(T &a,const T &b){return (a>b?(a=b,true):false);} templateistream &operator>>(istream &is,pair&p){is>>p.first>>p.second;return is;} templateistream &operator>>(istream &is,tuple&a){is>>std::get<0>(a)>>std::get<1>(a)>>std::get<2>(a);return is;} templateistream &operator>>(istream &is,array&a){for(auto&i:a)is>>i;return is;} templateistream &operator>>(istream &is,vector &a){for(auto &i:a)is>>i;return is;} templatevoid operator++(pair&a,int n){a.first++,a.second++;} templatevoid operator--(pair&a,int n){a.first--,a.second--;} templatevoid operator++(vector&a,int n){for(auto &i:a)i++;} templatevoid operator--(vector&a,int n){for(auto &i:a)i--;} #define overload3(_1,_2,_3,name,...) name #define rep1(i,n) for(int i=0;i<(int)(n);i++) #define rep2(i,l,r) for(int i=(int)(l);i<(int)(r);i++) #define rep(...) overload3(__VA_ARGS__,rep2,rep1)(__VA_ARGS__) #define reps(i,l,r) rep2(i,l,r) #define all(x) x.begin(),x.end() #define pcnt(x) __builtin_popcountll(x) #define fin(x) return cout<<(x)<<'\n',static_cast(0) #define yn(x) cout<<((x)?"Yes\n":"No\n") #define uniq(x) sort(all(x)),x.erase(unique(all(x)),x.end()) template inline int fkey(vector&z,T key){return lower_bound(z.begin(),z.end(),key)-z.begin();} ll myceil(ll a,ll b){return (a+b-1)/b;} template auto vec(const int (&d)[n],const T &init=T()){ if constexpr (id(d,init)); else return init; } #ifdef LOCAL #include #define SWITCH(a,b) (a) #else #define debug(...) static_cast(0) #define debugg(...) static_cast(0) #define SWITCH(a,b) (b) templateostream &operator<<(ostream &os,const pair&p){os<>testcase; for(int i=0;i struct Edge{ int from,to; T weight; int index; Edge(int from_,int to_,T weight_=T(),int index_=-1):from(from_),to(to_),weight(weight_),index(index_){} Edge():from(-1),to(-1),weight(),index(-1){} friend std::ostream &operator<<(std::ostream &os,const Edge&e){ os<<'['; os<<"from:"< struct Tree{ int n,r; std::vector>edge; std::vector>g; std::vectorptr; struct tree_range{ using iterator=typename std::vector>::iterator; iterator l,r; iterator begin()const{return l;} iterator end()const{return r;} int size()const{return r-l;} bool empty()const{return !size();} Edge &operator[](int i)const{return l[i];} }; struct const_tree_range{ using iterator=typename std::vector>::const_iterator; iterator l,r; iterator begin()const{return l;} iterator end()const{return r;} int size()const{return r-l;} bool empty()const{return !size();} const Edge &operator[](int i)const{return l[i];} }; explicit Tree(int n_):n(n_){ edge.reserve(n-1); } Tree():n(0){} Tree(int n_,const std::vector>&e,bool dir=false):n(n_),r(-1),edge(e){ if(!dir)build(); else{ std::vectorseen(n,false); ptr.resize(n+1); for(const Edge&i:edge)ptr[i.from]++,ptr[i.to]++,seen[i.to]=true; for(int i=1;i<=n;i++)ptr[i]+=ptr[i-1]; r=std::find(seen.begin(),seen.end(),false)-seen.begin(); assert(ptr[n]==n*2-2); g.resize(ptr[n]); for(const Edge&i:edge)g[--ptr[i.to]]=Edge(i.to,i.from,i.weight,i.index); for(const Edge&i:edge)g[--ptr[i.from]]=i; } } template void read(){ for(int i=0;i>u>>v; if constexpr(index)u--,v--; if constexpr(weighted)std::cin>>w; else w=1; edge.emplace_back(u,v,w,i); } build(); } template void readp(){ ptr.resize(n+1); for(int i=1;i>p; if constexpr(index)p--; edge.emplace_back(p,i,1,i-1); ptr[p]++; ptr[i]++; } for(int i=1;i<=n;i++)ptr[i]+=ptr[i-1]; g.resize(n*2-2); for(auto&&[u,v,w,i]:edge)g[--ptr[v]]=Edge(v,u,w,i); for(int i=0;ipar(n,-1); par[root]=-1; std::queueque; que.push(root); while(!que.empty()){ int x=que.front(); que.pop(); for(int i=ptr[x];i&e=g[i]; if(e.to!=par[x]){ par[e.to]=x; assert(e.indexbfs_order()const{ assert(is_directed()); std::vectorbfs(n); int p=0,q=0; bfs[q++]=root(); while(p&e:(*this)[x])bfs[q++]=e.to; } return bfs; } std::vectordfs_order()const{ assert(is_directed()); std::vectorres; res.reserve(n); std::vectorst(n); int p=0; st[p++]=root(); while(p){ int x=st[--p]; res.push_back(x); p+=(*this)[x].size(); for(const Edge&e:(*this)[x])st[--p]=e.to; p+=(*this)[x].size(); } return res; } std::vectorrbfs_order()const{ std::vectorbfs=bfs_order(); std::reverse(bfs.begin(),bfs.end()); return bfs; } void hld(){ assert(is_directed()); std::vectorsub(n); for(int x:rbfs_order()){ sub[x]=1; int mx=-1; for(Edge&e:(*this)[x]){ sub[x]+=sub[e.to]; if(mx,std::vector>in_out_order(){ assert(is_directed()); std::vectorin(n),out(n); int p=0; auto dfs=[&](auto self,int x)->void { in[x]=p++; for(const Edge&e:(*this)[x]){ self(self,e.to); } out[x]=p; }; dfs(dfs,root()); return std::make_pair(in,out); } std::pair>diameter()const{ assert(!is_directed()); static constexpr T inf=std::numeric_limits::max(); std::vectordst(n,inf); dst[0]=0; std::vectorque(n); int p=0,q=1; que[0]=0; while(p&e:(*this)[x])if(dst[e.to]==inf){ dst[e.to]=dst[x]+e.weight; que[q++]=e.to; } } int u=std::max_element(dst.begin(),dst.end())-dst.begin(); std::fill(dst.begin(),dst.end(),inf); dst[u]=0; p=0,q=1; que[0]=u; while(p&e:(*this)[x])if(dst[e.to]==inf){ dst[e.to]=dst[x]+e.weight; que[q++]=e.to; } } int v=std::max_element(dst.begin(),dst.end())-dst.begin(); T weight=dst[v]; std::vectorres; while(u!=v){ res.push_back(v); for(const Edge&e:(*this)[v])if(dst[e.to]& get_edge(int i)const{return edge[i];} inline int parent(int i)const{return i==r?-1:g[ptr[i+1]-1].to;} const Edge& parent_edge(int i)const{ assert(r!=-1&&i!=r); return g[ptr[i+1]-1]; } inline int root()const{return r;} typename std::vector>::iterator begin(){return edge.begin();} typename std::vector>::iterator end(){return edge.end();} typename std::vector>::const_iterator begin()const{return edge.begin();} typename std::vector>::const_iterator end()const{return edge.end();} }; struct StaticTopTree{ private: template void build(Treet){ int n=t.size(); left.reserve(n*2-1),right.reserve(n*2-1),par.reserve(n*2-1),A.reserve(n*2-1),B.reserve(n*2-1); left.resize(n,-1),right.resize(n,-1),par.resize(n,-1),A.resize(n),B.resize(n); for(int i=0;istd::pair { std::vector>vs{{0,x}}; while(t[x].size()>=1){ std::priority_queue,std::vector>,std::greater>>que; int heavy=t[x][0].to; que.emplace(0,heavy); for(int i=1;i=2){ auto [d1,v1]=que.top();que.pop(); auto [d2,v2]=que.top();que.pop(); if(B[v2]==heavy)std::swap(d1,d2),std::swap(v1,v2); int nv=left.size(); left.push_back(v1),right.push_back(v2),par.push_back(-1),A.push_back(x),B.push_back(B[v1]); par[v1]=par[v2]=nv; que.emplace(std::max(d1,d2)+1,nv); } vs.push_back(que.top()); while(true){ int sz=vs.size(); if(sz>=3&&(vs[sz-3].first==vs[sz-2].first||vs[sz-3].first<=vs[sz-1].first)){ int nv=left.size(); left.push_back(vs[sz-3].second),right.push_back(vs[sz-2].second),par.push_back(-1),A.push_back(A[vs[sz-3].second]),B.push_back(B[vs[sz-2].second]); par[vs[sz-3].second]=par[vs[sz-2].second]=nv; vs[sz-3].first=std::max(vs[sz-3].first,vs[sz-2].first)+1; vs[sz-3].second=nv; vs[sz-2]=vs[sz-1]; vs.pop_back(); } else if(sz>=2&&vs[sz-2].first<=vs[sz-1].first){ int nv=left.size(); left.push_back(vs[sz-2].second),right.push_back(vs[sz-1].second),par.push_back(-1),A.push_back(A[vs[sz-2].second]),B.push_back(B[vs[sz-1].second]); par[vs[sz-2].second]=par[vs[sz-1].second]=nv; vs[sz-2].first=std::max(vs[sz-2].first,vs[sz-1].first)+1; vs[sz-2].second=nv; vs.pop_back(); } else break; } x=heavy; } while((int)vs.size()>=2){ int sz=vs.size(); int nv=left.size(); left.push_back(vs[sz-2].second),right.push_back(vs[sz-1].second),par.push_back(-1),A.push_back(A[vs[sz-2].second]),B.push_back(B[vs[sz-1].second]); par[vs[sz-2].second]=par[vs[sz-1].second]=nv; vs[sz-2].first=std::max(vs[sz-2].first,vs[sz-1].first)+1; vs[sz-2].second=nv; vs.pop_back(); } return vs[0]; }; dfs(dfs,t.root()); } public: std::vectorleft,right,par,A,B; StaticTopTree(){} template explicit StaticTopTree(Treet,int){ build(std::move(t)); } template explicit StaticTopTree(Treet){ assert(t.is_directed()); t.hld(); build(std::move(t)); } }; template struct CentroidDecomposition:public Tree{ private: using Tree::Tree; using Tree::g; using Tree::ptr; using Tree::remove_parent; using Tree::hld; int boundaryA1,boundaryB1,boundaryA2,boundaryB2; std::vector>adj1,adj2; bool prepared=false; StaticTopTree stt; void prepare(){ if(prepared)return; remove_parent(); hld(); stt=StaticTopTree(*this,0); prepared=true; } public: template void run(const Func&f){ prepare(); int n=this->size(); auto dfs=[&](auto self,int nd)->std::vector> { if(nd>res(1); if(nd==0)res[0]=Edge(-1,0); else{ res[0]=g[ptr[nd+1]-1]; std::swap(res[0].from,res[0].to); } return res; } int lv=stt.left[nd],rv=stt.right[nd]; std::vector>lch=self(self,lv); std::vector>rch=self(self,rv); boundaryA1=stt.A[lv]; boundaryB1=stt.B[lv]; boundaryA2=stt.A[rv]; boundaryB2=stt.B[rv]; std::swap(adj1,lch); std::swap(adj2,rch); f(boundaryA1,boundaryA2); std::swap(adj1,lch); std::swap(adj2,rch); if(boundaryA1==boundaryA2){ if(std::ssize(lch)::tree_range get(int c,int x){ if(c==0){ if(x==boundaryA1)return typename Tree::tree_range{adj1.begin(),adj1.end()}; if(x==boundaryB1)return typename Tree::tree_range{g.begin()+ptr[x+1]-(!!x),g.begin()+ptr[x+1]}; return typename Tree::tree_range{g.begin()+ptr[x],g.begin()+ptr[x+1]}; } else if(c==1){ if(x==boundaryA2)return typename Tree::tree_range{adj2.begin(),adj2.end()}; if(x==boundaryB2)return typename Tree::tree_range{g.begin()+ptr[x+1],g.begin()+ptr[x+1]}; return typename Tree::tree_range{g.begin()+ptr[x],g.begin()+ptr[x+1]}; } else std::abort(); } typename Tree::const_tree_range get(int c,int x)const{ if(c==0){ if(x==boundaryA1)return typename Tree::const_tree_range{adj1.begin(),adj1.end()}; if(x==boundaryB1)return typename Tree::const_tree_range{g.begin()+ptr[x+1]-(!!x),g.begin()+ptr[x+1]}; return typename Tree::const_tree_range{g.begin()+ptr[x],g.begin()+ptr[x+1]}; } else if(c==1){ if(x==boundaryA2)return typename Tree::const_tree_range{adj2.begin(),adj2.end()}; if(x==boundaryB2)return typename Tree::const_tree_range{g.begin()+ptr[x+1],g.begin()+ptr[x+1]}; return typename Tree::const_tree_range{g.begin()+ptr[x],g.begin()+ptr[x+1]}; } else std::abort(); } CentroidDecomposition(const Tree&t){Tree::operator=(t);} }; #include #include constexpr int carmichael_constexpr(int n){ if(n==998244353)return 998244352; if(n==1000000007)return 1000000006; if(n<=1)return n; int res=1; int t=0; while(n%2==0){ n/=2; t++; } if(t==2)res=2; else if(t>=3)res=1<<(t-2); for(int i=3;i*i<=n;i++)if(n%i==0){ int c=0; while(n%i==0){ n/=i; c++; } int prod=i-1; for(int j=0;j struct mod_int{ private: static constexpr unsigned int umod=static_cast(m); static constexpr unsigned int car=carmichael_constexpr(m); using uint=unsigned int; using mint=mod_int; uint v; static_assert(mval()<=1)return *this; if constexpr(m%8==1){ mint b=2; while(b.pow((m-1)/2).val()==1)b++; int m2=m-1,e=0; while(m2%2==0)m2>>=1,e++; mint x=this->pow((m2-1)/2); mint y=(*this)*x*x; x*=*this; mint z=b.pow(m2); while(y.val()!=1){ int j=0; mint t=y; while(t.val()!=1)t*=t,j++; z=z.pow(1<<(e-j-1)); x*=z; z*=z; y*=z;e=j; } return x; } else if constexpr(m%8==5){ mint ret=this->pow((m+3)/8); if((ret*ret).val()==this->val())return ret; else return ret*mint::raw(2).pow((m-1)/4); } else{ return this->pow((m+1)/4); } } public: using value_type=uint; mod_int():v(0){} template,std::nullptr_t> =nullptr> mod_int(T a){ a%=m; if(a<0)v=a+umod; else v=a; } template,std::nullptr_t> =nullptr> mod_int(T a):v(a%umod){} static constexpr mint raw(int a){ mint ret; ret.v=a; return ret; } inline uint val()const{return this->v;} static constexpr int mod(){return m;} inline mint &operator+=(const mint &b){ this->v+=b.v; if(this->v>=umod)this->v-=umod; return *this; } inline mint &operator-=(const mint &b){ this->v-=b.v; if(this->v>=umod)this->v+=umod; return *this; } inline mint &operator*=(const mint &b){ this->v=((unsigned long long)this->v*b.v)%umod; return *this; } inline mint &operator/=(const mint &b){ *this*=b.inv(); return *this; } inline mint operator+()const{return *this;} inline mint operator-()const{return mint()-*this;} friend inline mint operator+(const mint &a,const mint &b){return mint(a)+=b;} friend inline mint operator-(const mint &a,const mint &b){return mint(a)-=b;} friend inline mint operator*(const mint &a,const mint &b){return mint(a)*=b;} friend inline mint operator/(const mint &a,const mint &b){return mint(a)/=b;} friend inline bool operator==(const mint &a,const mint &b){return a.val()==b.val();} friend inline bool operator!=(const mint &a,const mint &b){return !(a==b);} friend inline bool operator<(const mint &a,const mint &b){return a.val()(const mint &a,const mint &b){return a.val()>b.val();} friend inline bool operator<=(const mint &a,const mint &b){return a.val()<=b.val();} friend inline bool operator>=(const mint &a,const mint &b){return a.val()>=b.val();} inline mint operator++(int){ mint ret=*this; *this+=mint::raw(1); return ret; } inline mint operator--(int){ mint ret=*this; *this-=mint::raw(1); return ret; } mint pow(long long n)const{ mint ret=mint::raw(1),a(*this); while(n){ if(n&1)ret*=a; a*=a; n>>=1; } return ret; } inline mint inv()const{ assert(this->v!=0); return pow(car-1); } std::optionalsqrt()const{ if(this->val()<=1||this->pow((m-1)/2)==1)return std::make_optional(this->sqrt_impl()); else return std::nullopt; } static constexpr unsigned int order(){return car;} friend std::istream &operator>>(std::istream &is,mint &b){ long long a; is>>a; b=mint(a); return is; } friend std::ostream &operator<<(std::ostream &os,const mint &b){ os< struct std::hash>{ std::size_t operator()(mod_intx)const{ return std::hash()(x.val()); } }; using mint998=mod_int<998244353>; using mint107=mod_int<1000000007>; #include struct is_modint_impl{ template static auto check(T&&x)->decltype(x.mod(),std::true_type{}); template static auto check(...)->std::false_type; }; template struct is_modint:public decltype(is_modint_impl::check(std::declval())){}; template inline constexpr bool is_modint_v=is_modint::value; struct is_dynamic_modint_impl{ template static auto check(T&&x)->decltype(x.set_mod((typename T::value_type)0),std::true_type{}); template static auto check(...)->std::false_type; }; template struct is_dynamic_modint:public decltype(is_dynamic_modint_impl::check(std::declval())){}; template inline constexpr bool is_dynamic_modint_v=is_dynamic_modint::value; template inline constexpr bool is_static_modint_v=is_modint_v&&!is_dynamic_modint_v; struct is_uso_modint_impl{ template static auto check(T&&x)->decltype(x.uso(),std::true_type{}); template static auto check(...)->std::false_type; }; template struct is_uso_modint:public decltype(is_uso_modint_impl::check(std::declval())){}; template inline constexpr bool is_uso_modint_v=is_uso_modint::value; template struct F{ private: static int capacity; static std::vectorfact,factinv,inv; public: static void resize(int n){ if(capacity>=n)return; fact.resize(n+1),factinv.resize(n+1),inv.resize(n+1); for(int i=capacity+1;i<=n;i++){ fact[i]=fact[i-1]*T::raw(i); if constexpr(is_uso_modint_v)inv[i]=T(1)/T(i); else inv[i]=-inv[T::mod()%i]*(T::mod()/i); factinv[i]=factinv[i-1]*inv[i]; } capacity=n; } static T C(int n,int k){ if(n static T O(INT...k){ int n=0; for(int i:std::initializer_list{k...}){ if(i<0)return 0; n+=i; } resize(n); T ret=fact[n]; for(int i:std::initializer_list{k...})ret*=factinv[i]; return ret; } static T rising_factorial(int x,int n){ assert(n>=0); if(x>0){ resize(x+n-1); return fact[x+n-1]*factinv[x-1]; } else if(x+n>0)return T(); else{ resize(-x); T res=fact[-x]*factinv[-x-n]; if(n&1)res=-res; return res; } } static T falling_factorial(int x,int n){return rising_factorial(x-n+1,n);} }; templateint F::capacity=1; templatestd::vectorF::fact{1,1}; templatestd::vectorF::factinv{1,1}; templatestd::vectorF::inv{0,1}; template constexpr std::enable_if_t<(std::numeric_limits::digits<=32),T>pow_mod(T a,T n,T mod){ using u64=unsigned long long; u64 res=1; while(n>0){ if(n&1)res=((u64)res*a)%mod; a=((u64)a*a)%mod; n>>=1; } return T(res); } template constexpr std::enable_if_t<(std::numeric_limits::digits>32),T>pow_mod(T a,T n,T mod){ using u128=__uint128_t; u128 res=1; while(n>0){ if(n&1)res=((u128)res*a)%mod; a=((u128)a*a)%mod; n>>=1; } return T(res); } constexpr int primitive_root_constexpr(int x){ if(x==167772161)return 3; if(x==469762049)return 3; if(x==754974721)return 11; if(x==880803841)return 26; if(x==998244353)return 3; if(x==2)return 1; int x2=x; int p[20]={}; int c=0; x--; for(int i=2;i*i<=x;i++){ if(x%i==0){ p[c++]=i; while(x%i==0)x/=i; } } if(x!=1)p[c++]=x; x=x2; for(int g=2;;g++){ bool ok=true; for(int i=0;i template constexpr std::enable_if_t::digits<=32,int>msb(T n){return n==0?-1:31-__builtin_clz(n);} template constexpr std::enable_if_t<(std::numeric_limits::digits>32),int>msb(T n){return n==0?-1:63-__builtin_clzll(n);} template constexpr std::enable_if_t::digits<=32,int>lsb(T n){return n==0?-1:__builtin_ctz(n);} template constexpr std::enable_if_t<(std::numeric_limits::digits>32),int>lsb(T n){return n==0?-1:__builtin_ctzll(n);} template constexpr std::enable_if_t,T>floor_pow2(T n){return n==0?0:T(1)< constexpr std::enable_if_t,T>ceil_pow2(T n){return n<=1?1:T(1)<<(msb(n-1)+1);} template constexpr T safe_div(T a,T b){return a/b-(a%b&&(a^b)<0);} template constexpr T safe_ceil(T a,T b){return a/b+(a%b&&(a^b)>0);} template struct ntt_root{ static constexpr int rank2=lsb(m-1); static constexpr int g=primitive_root_constexpr(m); std::arrayroot,invroot; std::arrayrate2,invrate2; std::arrayrate3,invrate3; constexpr ntt_root(){ root[rank2]=pow_mod(g,m>>rank2,m); invroot[rank2]=pow_mod(root[rank2],m-2,m); for(int i=rank2-1;i>=0;i--){ root[i]=(long long)root[i+1]*root[i+1]%m; invroot[i]=(long long)invroot[i+1]*invroot[i+1]%m; } int prod=1,invprod=1; for(int i=0;i void dft(std::vector&a){ #ifdef NTT_SIMD if((int)a.size()>=32){ dft_simd(a); return; } #endif static constexpr ntt_rootr; static constexpr unsigned long long mod2=(unsigned long long)T::mod()*T::mod(); int n=a.size(); int h=lsb(n); int len=0; while(len void idft(std::vector&a){ #ifdef NTT_SIMD if((int)a.size()>=32){ idft_simd(a); return; } #endif static constexpr ntt_rootr; int n=a.size(); int h=lsb(n); int len=h; while(len){ if(len==1){ int p=1<<(h-1); for(int i=0;i std::vectorntt_convolution(std::vector a,std::vector b){ int n=a.size(),m=b.size(),s=n+m-1; if(std::min(n,m)<60){ if(n==0||m==0)return {}; std::vectorret(s,0); if(nc(z); for(int i=0;i std::enable_if_t,T>fast_factorial(int n){ if(n>=T::mod())return T(); static bool prepared=false; static std::vectorf; static constexpr int b=9; static constexpr int sz=T::mod()/(1<::resize(sz); f={1}; for(int i=0;ix(4<::inverse(j+1); for(int j=0;j<(1<::factorial_inv(j)*F::factorial_inv((1<::P((1<nf(2<x(s),y(s); for(int i=0;i::inverse(i+1); for(int i=0;i<(1<::factorial_inv(i)*F::factorial_inv((1<::P(i,1<=sz){ T res=n>=(1<n;i--)c*=T::raw(i); return f[((n+(1<>b)-1]/c; } } template T fast_comb(long long n,long long k){ if(n<0||k<0)return T(); T res=1; while(k){ long long n2=n%T::mod(),k2=k%T::mod(); n/=T::mod(),k/=T::mod(); if(n2(n2); res/=fast_factorial(k2); res/=fast_factorial(n2-k2); } return res; } using mint=mint998; void SOLVE(){ int n; ll k; cin>>n>>k; n++; vectora(n); cin>>a; CentroidDecomposition<> cd(n); cd.readp<0>(); vectordep(n); for(int x:cd.bfs_order()){ for(auto e:cd[x])dep[e.to]=dep[x]+1; } vectorans(a); vectorcoefs(n+10); rep(i,coefs.size())coefs[i]=fast_comb(k,i); cd.run([&](int a1,int a2){ if(a1==a2)return; vectorvals; auto dfs=[&](auto self,int x,int p,int dep)->void { if(x!=a2){ if(vals.size()<=dep)vals.resize(dep+1); vals[dep]+=a[x]; } for(auto e:cd.get(1,x))if(e.to!=p)self(self,e.to,x,dep+1); }; dfs(dfs,a2,-1,0); reverse(all(vals)); vals.pop_back(); vectorcoef(coefs.begin(),coefs.begin()+min(vals.size()+dep[a2]-dep[a1]+2,coefs.size())); vectorf=ntt_convolution(coef,vals); int v=a2; rep(i,vals.size(),f.size()){ ans[v]+=f[i]; v=cd.parent(v); if(v==a1)break; } }); rep(i,n)cout<