#include #if __has_include() #include #endif using namespace std; #define LL(...) ll __VA_ARGS__;lin(__VA_ARGS__) #define RDVL(T,n,...) vec__VA_ARGS__;fe(refs(__VA_ARGS__),e)e.get().resizes(n);lin(__VA_ARGS__) #define VL(n,...) RDVL(ll,n,__VA_ARGS__) #define fo(i,...) for(auto[i,i##stop,i##step]=for_range(0,__VA_ARGS__);i{}) #define binary_operator(op,type) auto operator op(const type&rhs)const{auto copy=*this;return copy op##=rhs;} #define defpp templatevoid 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 use_ml using ml=atcoder::modint; namespace my{ auto&operator<<(ostream&o,const atcoder::modint&x){return o<<(int)x.val();} void io(){cin.tie(nullptr)->sync_with_stdio(0);cout<concept modulary=requires(T t){t.mod();}; constexpr auto refs(auto&...a){return array{ref(a)...};} templateconstexpr auto for_range(T s,T b){T a=0;if(s)swap(a,b);return array{a-s,b,1-s*2};} templateconstexpr auto for_range(T s,T a,T b,T c=1){return array{a-s,b,(1-s*2)*c};} const string space{char(32)}; void lin(auto&...a){(cin>>...>>a);} templateusing pack_back_t=tuple_element_t>; } namespace my{ templateistream&operator>>(istream&i,vector&v){fe(v,e)i>>e;return i;} templateostream&operator<<(ostream&o,const vector&v){ll n=v.size();fo(i,n)o<constexpr int depth=0; templatestruct core_t_helper{using type=T;}; templateusing core_t=core_t_helper::type; 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{ static constexpr int D=depth+1; using C=core_t; using vector::vector; vec(const vector&v):vector(v){} void resizes(const auto&...a){if constexpr(sizeof...(a)==D)*this=make(a...,C{});else{ }} static auto make(ll n,const auto&...a){ if constexpr(sizeof...(a)==1)return vec(n,array{a...}[0]); else { } } ll size()const{return vector::size();} }; templaterequires(sizeof...(A)>=2)vec(const A&...a)->vec>>; } namespace my{ namespace fft{ using real=double; struct complex{ real x,y; complex()=default; complex(real x,real y):x(x),y(y){} inline complex operator+(const complex &c)const{return complex(x+c.x,y+c.y);} inline complex operator-(const complex &c)const{return complex(x-c.x,y-c.y);} inline complex operator*(const complex &c)const{return complex(x*c.x-y*c.y,x*c.y+y*c.x);} inline complex conj()const{return complex(x,-y);} }; const real PI=acosl(-1); ll base=1; vectorrts={{0,0},{1,0}}; vectorfft_rev={0,1}; void ensure_base(int nbase){ if(nbase<=base)return; fft_rev.resize(1<>1]>>1)+((i&1)<<(nbase-1)); while(base&a,int n){ assert((n&(n-1))==0); int zeros=__builtin_ctz(n); ensure_base(zeros); int shift=base-zeros; fo(i,n)if(i<(fft_rev[i]>>shift))swap(a[i],a[fft_rev[i]>>shift]); for(int k=1;kstruct arbitrary_mod_convolution{ using real=fft::real; using complex=fft::complex; arbitrary_mod_convolution(){} auto multiply(const vector&a,const vector&b,int need=-1){ if(need==-1)need=a.size()+b.size()-1; int nbase=0; while((1<fa(sz); fo(i,a.size())fa[i]=complex(a[i].val()&((1<<15)-1),a[i].val()>>15); fft::fast_fourier_transform(fa,sz); vectorfb(sz); if(a==b){ fb=fa; }else{ fo(i,b.size())fb[i]=complex(b[i].val()&((1<<15)-1),b[i].val()>>15); fft::fast_fourier_transform(fb,sz); } real ratio=0.25/sz; complex r2(0,-1),r3(ratio,0),r4(0,-ratio),r5(0,1); for(int i=0;i<=(sz>>1);i++){ int j=(sz-i)&(sz-1); complex a1=(fa[i]+fa[j].conj()); complex a2=(fa[i]-fa[j].conj())*r2; complex b1=(fb[i]+fb[j].conj())*r3; complex b2=(fb[i]-fb[j].conj())*r4; if(i!=j){ complex c1=(fa[j]+fa[i].conj()); complex c2=(fa[j]-fa[i].conj())*r2; complex d1=(fb[j]+fb[i].conj())*r3; complex d2=(fb[j]-fb[i].conj())*r4; fa[i]=c1*d1+c2*d2*r5; fb[i]=c1*d2+c2*d1; } fa[j]=a1*b1+a2*b2*r5; fb[j]=a1*b2+a2*b1; } fft::fast_fourier_transform(fa,sz); fft::fast_fourier_transform(fb,sz); vectorret(need); fo(i,need){ int64_t aa=llround(fa[i].x); int64_t bb=llround(fb[i].x); int64_t cc=llround(fa[i].y); aa=T(aa).val(),bb=T(bb).val(),cc=T(cc).val(); ret[i]=aa+(bb<<15)+(cc<<30); } return ret; } }; templatestruct formal_power_series:vec{ using vec::vec; using fps=formal_power_series; static inline arbitrary_mod_convolutionfft; static fps mul(const fps&a,const fps&b){ if constexpr(!modulary){ } else if constexpr(is_same_v){ } else return fft.multiply(a,b); } fps&operator*=(const fps&g){return*this=(this->size()&&g.size()?mul(*this,g):fps{});} binary_operator(*,fps) }; templateusing fps=formal_power_series; } namespace my{entry void main(){ LL(N); VL(N+1,a); LL(M); VL(M+1,b); use_ml ml::set_mod(258280327); fpsf(a.size()); fpsg(b.size()); fo(i,f.size())f[i]=a[i]; fo(i,g.size())g[i]=b[i]; if(a==vec(N+1)||b==vec(M+1)){ pp(0); pp(0); return; } auto h=f*g; pp(h.size()-1); pp(h); }}