//#define _GLIBCXX_DEBUG
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ld long double
#define al(a) (a).begin(),(a).end()
#define mk make_pair
#define check cout<<"?"<<endl;

ll MOD=1000000007;
ll mod=998244353;
int inf=1000001000;
ll INF=1e18+5;

class FFT{
public:
    ll MOD_NTT;
    ll pr;
    int sz;
    ll inv_sz=1;
    ll lt,rt;
    vector<ll> f,g,fgd,zeta,c;

    // pr 原始根
    // nr sz乗根
    FFT(const vector<ll>& a,const vector<ll>& b,ll MOD_in):sz{(int)a.size()+(int)b.size()},MOD_NTT{MOD_in}{
        f.assign((int)a.size(),0);
        g.assign((int)b.size(),0);
        rep(i,(int)a.size()) f[i]=a[i];
        rep(i,(int)b.size()) g[i]=b[i];
        int n=1;
        while(n<sz){
            n<<=1; inv_sz=inv_sz*((MOD_NTT+1)>>1)%MOD_NTT;
        }
        sz=n;
        if((MOD_NTT-1)%sz!=0){
            cout<<"error"<<endl;
            return;
        }
        pr=get_pr();
        if(pr==-1) return;
        ll nr=power(pr,(MOD_NTT-1)/sz);
        zeta.assign(sz,1);
        fgd.assign(sz,0);
        c.assign(sz,0);
        for(int i=1;i<sz;i++) zeta[i]=zeta[i-1]*nr%MOD_NTT;
        dft_f(0,sz,0,0);
        dft_g(0,sz,0,0);
        idft(0,sz,0,0);
    }

    ll power(ll num,ll pw){
        ll res=1;
        while(pw>0){
            if(pw&1) res=res*num%MOD_NTT;
            num=num*num%MOD_NTT;
            pw>>=1;
        }
        return res;
    }

    int get_pr(){
        int num=MOD_NTT-1;
        bool judge;
        vector<int> fac(0);
        for(ll i=2;i*i<=num;i++){
            judge=false;
            while(num%i==0){
                num/=i;
                judge=true;
            }
            if(judge) fac.push_back(i);
        }
        if(num>1) fac.push_back(num);

        for(int i=2;i<MOD_NTT;i++){
            if(power(i,MOD_NTT-1)!=1){
                cout<<"error(MOD is not prime.)"<<endl;
                return -1;
            }
            judge=true;
            for(auto p:fac){
                if(power(i,(MOD_NTT-1)/p)==1){
                    judge=false;
                    break;
                }
            }
            if(judge) return i;
        }
    }

    //dft(0,sz,0,0);
    void dft_f(int a,int len,int k,int idx){
        if(len==1){
            c[a]=0;
            if(idx<f.size()) c[a]=f[idx];
            return;
        }
        dft_f(a,len>>1,k+1,idx);
        dft_f(a+(len>>1),len>>1,k+1,idx+(1<<k));
        rep(i,len>>1){
            lt=c[a+i%(len>>1)]; rt=c[a+i%(len>>1)+(len>>1)];
            c[a+i]=(lt+zeta[sz/len*i]*rt%MOD_NTT)%MOD_NTT;
            c[a+i+(len>>1)]=(lt+zeta[sz/len*i+(sz>>1)]*rt%MOD_NTT)%MOD_NTT;
        }
        if(k==0)rep(i,sz) fgd[i]=c[i];
    }

    //dft(0,sz,0,0);
    void dft_g(int a,int len,int k,int idx){
        if(len==1){
            c[a]=0;
            if(idx<g.size()) c[a]=g[idx];
            return;
        }
        dft_g(a,len>>1,k+1,idx);
        dft_g(a+(len>>1),len>>1,k+1,idx+(1<<k));
        rep(i,len>>1){
            lt=c[a+i%(len>>1)]; rt=c[a+i%(len>>1)+(len>>1)];
            c[a+i]=(lt+zeta[sz/len*i]*rt%MOD_NTT)%MOD_NTT;
            c[a+i+(len>>1)]=(lt+zeta[sz/len*i+(sz>>1)]*rt%MOD_NTT)%MOD_NTT;
        }
        if(k==0)rep(i,sz) fgd[i]=fgd[i]*c[i]%MOD_NTT;
    }

    //idft(0,sz,0,0);
    void idft(int a,int len,int k,int idx){
        if(len==1){
            c[a]=fgd[idx];
            return;
        }
        idft(a,len>>1,k+1,idx);
        idft(a+(len>>1),len>>1,k+1,idx+(1<<k));
        rep(i,len>>1){
            lt=c[a+i%(len>>1)]; rt=c[a+i%(len>>1)+(len>>1)];
            c[a+i]=(lt+zeta[(sz-(sz/len*i))%sz]*rt%MOD_NTT)%MOD_NTT;
            c[a+i+(len>>1)]=(lt+zeta[((sz>>1)-(sz/len*i))%sz]*rt%MOD_NTT)%MOD_NTT;
        }
        if(k==0)rep(i,sz) c[i]=c[i]*inv_sz%MOD_NTT;
    }

    void print(const vector<ll>& v){
        rep(i,v.size()) cout<<v[i]<<" ";
        cout<<endl;
    }
};

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    ll n,m; cin>>n>>m;
    vector<ll> a(n,0),b(m,0);
    rep(i,n) cin>>a[i];
    rep(i,m) cin>>b[i];
    FFT fft{a,b,mod};
    rep(i,n+m-1) printf("%lld ",fft.c[i]);
    printf("\n");
}


Measured memory_bytes: 51864