//#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,h=0;
    ll inv_sz=1;
    //ll lt,rt;
    //vector<ll> zeta;

    // pr 原始根
    // nr sz乗根
    FFT(vector<ll> a,vector<ll> b,ll MOD_in):MOD_NTT{MOD_in}{
        int n=(int)a.size(),m=(int)b.size();
        int N=1;
        while(N<n+m-1){
            N<<=1; inv_sz=inv_sz*((MOD_NTT+1)>>1)%MOD_NTT;
            h++;
        }
        sz=N;
        a.resize(sz);
        b.resize(sz);
        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);
        //for(int i=1;i<sz;i++) zeta[i]=zeta[i-1]*nr%MOD_NTT;

        dft(a);
        dft(b);
        for(int i=0;i<sz;i++) a[i]=a[i]*b[i]%MOD_NTT;
        idft(a);
        a.resize(n+m-1);
        for(int i=0;i<n+m-1;i++){
            a[i]=a[i]*inv_sz%MOD_NTT;
            printf("%lld ",a[i]);
        }
        printf("\n");
    }

    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(){
        if(MOD_NTT==2) return 1;
        if(MOD_NTT==167772161) return 3;
        if(MOD_NTT==469762049) return 3;
        if(MOD_NTT==754974721) return 11;
        if(MOD_NTT==998244353) return 3;
        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++){
            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(int a,int len,int k,int idx){
        if(len==1){
            c[a]=0;
            if(idx<f.size()) c[a]=f[idx];
            return;
        }
        dft(a,len>>1,k+1,idx);
        dft(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];
    }
*/

    void dft(vector<ll>& a){
        static bool first=true;
        static ll sum_e[30];
        if(first){
            first=false;
            ll es[30],ies[30];
            int cnt2=0;
            while(((1<<cnt2)&(MOD_NTT-1))==0) cnt2++;
            ll e=power(pr,(MOD_NTT-1)>>cnt2);
            ll ie=power(e,MOD_NTT-2);
            for(int i=cnt2;i>=2;i--){
                es[i-2]=e;
                ies[i-2]=ie;
                e=e*e%MOD_NTT;
                ie=ie*ie%MOD_NTT;
            }
            ll cur=1;
            for(int i=0;i<cnt2-2;i++){
                sum_e[i]=es[i]*cur%MOD_NTT;
                cur=cur*ies[i]%MOD_NTT;
            }
        }
        for(int ph=1;ph<=h;ph++){
            int w=1<<(ph-1),p=1<<(h-ph);
            ll cur=1;
            for(int s=0;s<w;s++){
                int offset=s<<(h-ph+1);
                for(int i=0;i<p;i++){
                    auto l=a[i+offset];
                    auto r=a[i+offset+p]*cur%MOD_NTT;
                    a[i+offset]=(l+r);
                  if(a[i+offset]>=MOD_NTT) a[i+offset]-=MOD_NTT;
                    a[i+offset+p]=(l-r+MOD_NTT);
                  if(a[i+offset+p]>=MOD_NTT) a[i+offset+p]-=MOD_NTT;
                }
                unsigned int N=~(unsigned int)(s);
                int idx=0;
                while(((1U<<idx)&(N))==0) idx++;
                cur=cur*sum_e[idx]%MOD_NTT;
            }
        }
    }

    void idft(vector<ll>& a){
        static bool first=true;
        static ll sum_ie[30];
        if(first){
            first=false;
            ll es[30],ies[30];
            int cnt2=0;
            while(((1<<cnt2)&(MOD_NTT-1))==0) cnt2++;
            ll e=power(pr,(MOD_NTT-1)>>cnt2);
            ll ie=power(e,MOD_NTT-2);
            for(int i=cnt2;i>=2;i--){
                es[i-2]=e;
                ies[i-2]=ie;
                e=e*e%MOD_NTT;
                ie=ie*ie%MOD_NTT;
            }
            ll cur=1;
            for(int i=0;i<cnt2-2;i++){
                sum_ie[i]=ies[i]*cur%MOD_NTT;
                cur=cur*es[i]%MOD_NTT;
            }
        }
        for(int ph=h;ph>=1;ph--){
            int w=1<<(ph-1),p=1<<(h-ph);
            ll icur=1;
            for(int s=0;s<w;s++){
                int offset=s<<(h-ph+1);
                for(int i=0;i<p;i++){
                    auto l=a[i+offset];
                    auto r=a[i+offset+p];
                    a[i+offset]=(l+r)%MOD_NTT;
                  if(a[i+offset]>=MOD_NTT) a[i+offset]-=MOD_NTT;
                    a[i+offset+p]=(MOD_NTT+l-r)*icur%MOD_NTT;
                  if(a[i+offset+p]>=MOD_NTT) a[i+offset+p]-=MOD_NTT;
                }
                unsigned int N=~(unsigned int)(s);
                int idx=0;
                while(((1U<<idx)&(N))==0) idx++;
                icur=icur*sum_ie[idx]%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{a,b,mod};
}


Measured memory_bytes: 35424