#include<bits/stdc++.h>
using namespace std;
//#define int long long
#define REP(i,m,n) for(int i=(m);i<(n);i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define all(a) a.begin(),a.end()
#define rall(c) (c).rbegin(),(c).rend()
#define mp make_pair
#define endl '\n'
#define vec vector<ll>
#define mat vector<vector<ll> >
#define fi first
#define se second
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll> pll;
typedef long double ld;
typedef complex<double> comp;
const ll INF=1e9+7;
const ll MOD=998244353;
const int MAX=200010;

struct NumberTheoreticTransform
{
  int mod;
  int primitiveroot;

  NumberTheoreticTransform(int mod, int root) : mod(mod), primitiveroot(root) {}

  inline int mod_pow(int x, int n)
  {
    int ret = 1;
    while(n > 0) {
      if(n & 1) ret = mul(ret, x);
      x = mul(x, x);
      n >>= 1;
    }
    return ret;
  }

  inline int inverse(int x)
  {
    return (mod_pow(x, mod - 2));
  }

  inline int add(unsigned x, int y)
  {
    x += y;
    if(x >= mod) x -= mod;
    return (x);
  }

  inline int mul(int a, int b)
  {
    unsigned long long x = (long long) a * b;
    unsigned xh = (unsigned) (x >> 32), xl = (unsigned) x, d, m;
    asm("divl %4; \n\t" : "=a" (d), "=d" (m) : "d" (xh), "a" (xl), "r" (mod));
    return (m);
  }

  void DiscreteFourierTransform(vector< int > &F, bool rev)
  {
    const int N = (int) F.size();
    for(int i = 0, j = 1; j + 1 < N; j++) {
      for(int k = N >> 1; k > (i ^= k); k >>= 1);
      if(i > j) swap(F[i], F[j]);
    }
    int w, wn, s, t;
    for(int i = 1; i < N; i <<= 1) {
      w = mod_pow(primitiveroot, (mod - 1) / (i * 2));
      if(rev) w = inverse(w);
      for(int k = 0; k < i; k++) {
        wn = mod_pow(w, k);
        for(int j = 0; j < N; j += i * 2) {
          s = F[j + k], t = mul(F[j + k + i], wn);
          F[j + k] = add(s, t), F[j + k + i] = add(s, mod - t);
        }
      }
    }
    if(rev) {
      int temp = inverse(N);
      for(int i = 0; i < N; i++) F[i] = mul(F[i], temp);
    }
  }

  vector< int > Multiply(const vector< int > &A, const vector< int > &B)
  {
    int sz = 1;
    while(sz < A.size() + B.size() - 1) sz <<= 1;
    vector< int > F(sz), G(sz);
    for(int i = 0; i < A.size(); i++) F[i] = A[i];
    for(int i = 0; i < B.size(); i++) G[i] = B[i];
    DiscreteFourierTransform(F, false);
    DiscreteFourierTransform(G, false);
    for(int i = 0; i < sz; i++) F[i] = mul(F[i], G[i]);
    DiscreteFourierTransform(F, true);
    F.resize(A.size() + B.size() - 1);
    return (F);
  }
};

inline int add(unsigned x, int y, int mod)
{
  x += y;
  if(x >= mod) x -= mod;
  return (x);
}

inline int mul(int a, int b, int mod)
{
  unsigned long long x = (long long) a * b;
  unsigned xh = (unsigned) (x >> 32), xl = (unsigned) x, d, m;
  asm("divl %4; \n\t" : "=a" (d), "=d" (m) : "d" (xh), "a" (xl), "r" (mod));
  return (m);
}

inline int mod_pow(int x, int n, int mod)
{
  int ret = 1;
  while(n > 0) {
    if(n & 1) ret = mul(ret, x, mod);
    x = mul(x, x, mod);
    n >>= 1;
  }
  return ret;
}

inline int inverse(int x, int mod)
{
  return (mod_pow(x, mod - 2, mod));
}

vector< int > AnyModNTTMultiply(vector< int >& a, vector< int >& b, int mod)
{
  for(auto &x : a) x %= mod;
  for(auto &x : b) x %= mod;
  NumberTheoreticTransform ntt1(167772161, 3);
  NumberTheoreticTransform ntt2(469762049, 3);
  NumberTheoreticTransform ntt3(1224736769, 3);
  auto x = ntt1.Multiply(a, b);
  auto y = ntt2.Multiply(a, b);
  auto z = ntt3.Multiply(a, b);
  const int m1 = ntt1.mod, m2 = ntt2.mod, m3 = ntt3.mod;
  const int m1_inv_m2 = inverse(m1, m2);
  const int m12_inv_m3 = inverse(mul(m1, m2, m3), m3);
  const int m12_mod = mul(m1, m2, mod);
  vector< int > ret(x.size());
  for(int i = 0; i < x.size(); i++) {
    int v1 = mul(add(y[i], m2 - x[i], m2), m1_inv_m2, m2);
    int v2 = mul(add(z[i], m3 - add(x[i], mul(m1, v1, m3), m3), m3), m12_inv_m3, m3);
    ret[i] = add(x[i], add(mul(m1, v1, mod), mul(m12_mod, v2, mod), mod), mod);
  }
  return ret;
}

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,m;cin>>n>>m;
    vector<int>a(n);
    vector<int>b(m);
    rep(i,n){
        cin>>a[i];
    }
    rep(i,m){
        cin>>b[i];
    }
    vector<int>c;
    c=AnyModNTTMultiply(a,b,MOD);
    rep(i,n+m-1){
        cout<<c[i]<<' ';
    }
    cout<<endl;
}

Measured memory_bytes: 27212