#include<bits/stdc++.h> using namespace std; const int maxn=3000005; const double pi=acos(-1.0); inline int read(){ int x=0,f=1; char ch=getchar(); while(ch<‘0‘||ch>‘9‘){if(ch==‘-‘)f=-1;ch=getchar();} while(ch>=‘0‘&&ch<=‘9‘){x=x*10+ch-‘0‘;ch=getchar();} return x*f; } struct Complex{//复数类 double r,i; Complex(){} Complex(double a,double b):r(a),i(b){} Complex operator+(const Complex &a)const{ return Complex(r+a.r,i+a.i); } Complex operator-(const Complex &a)const{ return Complex(r-a.r,i-a.i); } Complex operator*(const Complex &a)const{ return Complex(r*a.r-i*a.i,r*a.i+i*a.r); } }a[maxn],b[maxn]; int r[maxn],n,m; void fft(Complex *a,int x){//x=1,DFT;x=-1,IDFT for(int i=0;i<n;i++) if(i<r[i]) swap(a[i],a[r[i]]);//翻转操作 for(int i=1;i<n;i<<=1){ Complex wn(cos(pi/i),x*sin(pi/i));//旋转因子 for(int j=0;j<n;j+=(i<<1)){ Complex w(1,0);//单位复数根 for(int k=0;k<i;k++){ //蝴蝶变换 Complex t=w*a[j+k+i]; a[j+k+i]=a[j+k]-t; a[j+k]=a[j+k]+t; w=w*wn; } } } if(x==-1) for(int i=0;i<=n;i++) a[i].r=a[i].r/n; } int main(){ n=read(),m=read(); for(int i=0;i<=n;i++) a[i].r=read(),a[i].i=0; for(int i=0;i<=m;i++) b[i].r=read(),b[i].i=0; m+=n;int l=0; for(n=1;n<=m;n<<=1) ++l; for(int i=0;i<n;i++) r[i]=(r[i>>1]>>1)|((i&1)<<(l-1));//长度为l的二进制位翻转 fft(a,1);fft(b,1);//求点值 for(int i=0;i<=n;i++) a[i]=a[i]*b[i]; fft(a,-1);//求系数 for(int i=0;i<=m;i++) printf("%d ",(int)(a[i].r+0.5)); }