1 #include<iostream>
2 #include<cstdio>
3 #include<cmath>
4 #include<algorithm>
5 #include<queue>
6 #include<cstring>
7 #define PAU putchar(' ')
8 #define ENT putchar('\n')
9 using namespace std;
10 const int maxm=300000+10,maxn=100000+10;
11 const double pi=acos(-1.0);
12 struct fft{
13 struct cx{
14 double r,i;cx(double _r=0.0,double _i=0.0){r=_r;i=_i;}
15 cx operator+(const cx&a){return cx(r+a.r,i+a.i);}
16 cx operator-(const cx&a){return cx(r-a.r,i-a.i);}
17 cx operator*(const cx&a){return cx(r*a.r-i*a.i,r*a.i+i*a.r);}
18 }f[maxm];int len;
19 void init(int*s,int L,int len){
20 this->len=len;for(int i=0;i<L;i++)f[i]=cx(s[L-i-1],0.0);return;
21 }
22 void change(){
23 for(int i=1,j=len>>1;i<len-1;i++){
24 if(i<j)swap(f[i],f[j]);int k=len>>1;
25 while(j>=k)j-=k,k>>=1;if(j<k)j+=k;
26 } return;
27 }
28 void cal(int tp){
29 change();double tm=-tp*2*pi;
30 for(int i=2;i<=len;i<<=1){
31 double tr=tm/i;cx wn(cos(tr),sin(tr));
32 for(int j=0;j<len;j+=i){
33 cx w(1,0);int tn=i>>1;
34 for(int k=j;k<j+tn;k++){
35 cx u=f[k],t=w*f[k+tn];
36 f[k]=u+t;f[k+tn]=u-t;w=w*wn;
37 }
38 }
39 }if(tp<0) for(int i=0;i<len;i++) f[i].r/=len;return;
40 }
41 };
42 void mul(int*s,int*t,int L1,int L2,int&L,int*ans){
43 L=1;while(L<L1<<1||L<L2<<1)L<<=1;static fft a,b;
44 a.init(s,L1,L);b.init(t,L2,L);a.cal(1);b.cal(1);
45 for(int i=0;i<L;i++) a.f[i]=a.f[i]*b.f[i];a.cal(-1);
46 for(int i=0;i<L;i++) ans[i]=(int)(a.f[i].r+0.5);return;
47 }
48 inline int read(){
49 int x=0,sig=1;char ch=getchar();
50 while(!isdigit(ch)){if(ch=='-') sig=-1;ch=getchar();}
51 while(isdigit(ch)) x=10*x+ch-'0',ch=getchar();
52 return x*sig;
53 }
54 inline void write(int x){
55 if(x==0){putchar('0');return;}if(x<0) putchar('-'),x=-x;
56 int len=0,buf[15];while(x) buf[len++]=x%10,x/=10;
57 for(int i=len-1;i>=0;i--) putchar(buf[i]+'0');return;
58 }
59 int s[maxn],t[maxn],ans[maxm],L1,L2,L;
60 void init(){
61 L1=read()+1;L2=read()+1;
62 for(int i=0;i<L1;i++) s[i]=read();
63 for(int i=0;i<L2;i++) t[i]=read();
64 mul(s,t,L1,L2,L,ans);
65 return;
66 }
67 void work(){
68 int lim=L1+L2-2;
69 for(L--;!ans[L]&&L&&L>lim;L--);
70 for(int i=L;i>=0;i--) write(ans[i]),PAU;
71 return;
72 }
73 void print(){
74 return;
75 }
76 int main(){init();work();print();return 0;}