1 #include<bits/stdc++.h>//只是在虚数部分改了一下 2 using namespace std; 3 typedef long long int ll; 4 const ll maxn=1E6+5; 5 const ll mod=998244353; 6 const ll G=3; 7 const ll Gi=332748118; 8 ll n,m,limit,r[maxn*4],len,f[maxn],g[maxn]; 9 ll qpow(ll x,ll y) 10 { 11 ll ans=1,base=x; 12 while(y) 13 { 14 if(y&1)ans=ans*base%mod; 15 base=base*base%mod; 16 y>>=1; 17 } 18 return ans; 19 } 20 int re(int x) 21 { 22 int sum=0; 23 for(int i=0;i<len;++i)sum=sum*2+((x&(1<<i))>0); 24 return sum; 25 } 26 void FFT(ll*A,int g) 27 { 28 for(int i=0;i<limit;++i) 29 if(i<r[i])swap(A[i],A[r[i]]); 30 for(int i=2;i<=limit;i*=2) 31 { 32 ll w; 33 if(g==1)w=qpow(G,(mod-1)/i); 34 else w=qpow(Gi,(mod-1)/i); 35 for(int j=0;j<limit/i;++j) 36 { 37 ll d=1; 38 for(int k=0;k<i/2;++k) 39 { 40 ll a=A[i*j+k],b=d*A[i*j+i/2+k]%mod; 41 A[i*j+k]=(a+b)%mod; 42 A[i*j+i/2+k]=(a-b+mod)%mod; 43 d=d*w%mod; 44 } 45 } 46 } 47 } 48 int main() 49 { 50 ios::sync_with_stdio(false); 51 cin>>n>>m; 52 for(int i=0;i<=n;++i)cin>>f[i]; 53 for(int i=0;i<=m;++i)cin>>g[i]; 54 limit=1; 55 len=0; 56 while(limit<=n+m+1) 57 { 58 limit*=2; 59 ++len; 60 } 61 for(int i=0;i<limit;++i)r[i]=re(i); 62 FFT(f,1); 63 FFT(g,1); 64 for(int i=0;i<=limit;++i)f[i]=f[i]*g[i]; 65 FFT(f,-1); 66 ll g=qpow(limit,mod-2); 67 for(int i=0;i<=n+m;++i)cout<<(f[i]*g%mod+mod)%mod<<' '; 68 cout<<endl; 69 return 0; 70 }