//#include "bits/stdc++.h"

#define _USE_MATH_DEFINES
#include<cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <deque>
#include <algorithm>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <unordered_map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <iterator>
#include<iomanip>
#include<complex>
#include<assert.h>

using namespace std;

#define rep(i,a,b) for(int i=(a), i##_len=(b);i<i##_len;i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)

#define int ll
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair

//typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<int, double> pid;
typedef pair<double, int> pdi;
typedef pair<double, double> pdd;
typedef vector< vector<int> > mat;

template<class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (b < a) { a = b; return true; } return false; }

const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)1e9 + 7;

const double EPS = 1e-9;

template<class T> T extgcd(T a, T b, T& x, T& y)
{
	for (T u = y = 1, v = x = 0; a;)
	{
		T q = b / a;
		swap(x -= q * u, u);
		swap(y -= q * v, v);
		swap(b -= q * a, a);
	}
	return b;
}

template<class T> T mod_inv(T a, T m)
{
	T x, y;
	extgcd(a, m, x, y);
	return (m + x % m) % m;
}

ll mod_pow(ll a, ll n, ll mod)
{
	ll ret = 1;
	ll p = a % mod;
	while (n)
	{
		if (n & 1) ret = ret * p % mod; p = p * p % mod;
		n >>= 1;
	} return ret;
}


template<int mod, int primitive_root>
class NTT {
public:
	int get_mod() const { return mod; }
	void _ntt(vector<ll>& a, int sign) {
		const int n = SZ(a);
		assert((n ^ (n&-n)) == 0);

		const int g = 3;
		int h = (int)mod_pow(g, (mod - 1) / n, mod);
		if (sign == -1) h = (int)mod_inv(h, mod);

		int i = 0;
		for (int j = 1; j < n - 1; ++j) {
			for (int k = n >> 1; k > (i ^= k); k >>= 1);
			if (j < i) swap(a[i], a[j]);
		}

		for (int m = 1; m < n; m *= 2) {
			const int m2 = 2 * m;
			const ll base = mod_pow(h, n / m2, mod);
			ll w = 1;
			rep(x, 0, m) {
				for (int s = x; s < n; s += m2) {
					ll u = a[s];
					ll d = a[s + m] * w % mod;
					a[s] = u + d;
					if (a[s] >= mod) a[s] -= mod;
					a[s + m] = u - d;
					if (a[s + m] < 0) a[s + m] += mod;
				}
				w = w * base % mod;
			}
		}

		for (auto& x : a) if (x < 0) x += mod;
	}
	void ntt(vector<ll>& input) {
		_ntt(input, 1);
	}
	void intt(vector<ll>& input) {
		_ntt(input, -1);
		const int n_inv = mod_inv(SZ(input), mod);
		for (auto& x : input) x = x * n_inv % mod;
	}

	vector<ll> convolution(const vector<ll>& a, const vector<ll>& b) {
		int ntt_size = 1;
		while (ntt_size < SZ(a) + SZ(b)) ntt_size *= 2;

		vector<ll> _a = a, _b = b;
		_a.resize(ntt_size); _b.resize(ntt_size);

		ntt(_a);
		ntt(_b);

		rep(i, 0, ntt_size) {
			(_a[i] *= _b[i]) %= mod;
		}

		intt(_a);
		return _a;
	}
};

typedef NTT<167772161, 3> NTT_1;
typedef NTT<469762049, 3> NTT_2;
typedef NTT<1224736769, 3> NTT_3;

vector<ll> fast_int32mod_convolution(vector<ll> a, vector<ll> b, int mod) {
	for (auto& x : a) x %= mod;
	for (auto& x : b) x %= mod;

	NTT_1 ntt1; NTT_2 ntt2; NTT_3 ntt3;
	auto x = ntt1.convolution(a, b);
	auto y = ntt2.convolution(a, b);
	auto z = ntt3.convolution(a, b);

	const ll m1 = ntt1.get_mod(), m2 = ntt2.get_mod(), m3 = ntt3.get_mod();
	const ll m1_inv_m2 = mod_inv<ll>(m1, m2);
	const ll m12_inv_m3 = mod_inv<ll>(m1 * m2, m3);
	const ll m12_mod = m1 * m2 % mod;
	vector<ll> ret(SZ(x));
	rep(i, 0, SZ(x)) {
		ll v1 = (y[i] - x[i]) *  m1_inv_m2 % m2;
		if (v1 < 0) v1 += m2;
		ll v2 = (z[i] - (x[i] + m1 * v1) % m3) * m12_inv_m3 % m3;
		if (v2 < 0) v2 += m3;
		ll constants3 = (x[i] + m1 * v1 + m12_mod * v2) % mod;
		if (constants3 < 0) constants3 += mod;
		ret[i] = constants3;
	}

	return ret;
}

// const int mods[] = { 1224736769, 469762049, 167772161, 595591169, 645922817, 897581057, 998244353 };

/*void comvolution_test() {
	NTT_1 ntt1;

	vector<ll> v = { 1, 2, 3 };
	vector<ll> u = { 4, 5, 6 };

	auto vu = ntt1.convolution(v, u);
}

void int32mod_convolution_test() {
	vector<ll> x, y;
	rep(i, 0, 10) x.push_back((int)1e8 + i);
	y = x;

	auto z = fast_int32mod_convolution(x, y, (int)1e9 + 7);
	z.resize(SZ(x) + SZ(y) - 1);
}*/

signed main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);

	NTT<998244353, 3> ntt1;

	int N, M;
	cin >> N >> M;

	vector<long long> A(N), B(M);
	rep(i, 0, N)cin >> A[i];
	rep(i, 0, M)cin >> B[i];

	auto C = ntt1.convolution(A, B);

	rep(i, 0, N + M - 1)
	{
		cout << C[i];
		if (i == N + M - 2)cout << endl;
		else cout << " ";
	}

	return 0;
}

Measured memory_bytes: 31992