#include <bits/stdc++.h>
using namespace std;
#define N 100001
#define L 18 /* L = ceil(log2(N * 2 - 1)) */
#define N_ (1 << L)
#define MD 469762049 /* MD = 56 * 2^23 + 1 */
int *wu[L + 1], *wv[L + 1];
int power(int a, int k) {
long long b = a, p = 1;
while (k) {
if (k & 1)
p = p * b % MD;
b = b * b % MD;
k >>= 1;
}
return p;
}
void init() {
int l, i, u, v;
/* u ^ n must be equal to 1 for FFT */
/* since x ^ (MD - 1) = 1 (mod MD) by fermat's little theorem */
/* so MD - 1 must be power of 2 as n is a power of 2 */
u = power(3, (MD - 1) >> L);
/* v is u ^ -1 = u ^ (MD - 2) by fermat's little theorem */
/* this is for interpolation (inverse FFT) */
v = power(u, MD - 2);
/* find the powers of u and v for each possible n */
for (l = L; l > 0; l--) {
int n = 1 << (l - 1);
wu[l] = (int *) malloc(n * sizeof *wu[l]);
wv[l] = (int *) malloc(n * sizeof *wv[l]);
wu[l][0] = wv[l][0] = 1;
for (i = 1; i < n; i++) {
wu[l][i] = (long long) wu[l][i - 1] * u % MD;
wv[l][i] = (long long) wv[l][i - 1] * v % MD;
}
/* change u and for next iteration of n, which becomes n / 2 */
/* u ^ n = 1 => (u ^ (n / 2)) ^ 2 = 1 */
/* same goes for v */
u = (long long) u * u % MD, v = (long long) v * v % MD;
}
}
void ntt_(int *aa, int l, int inverse) {
if (l > 0) {
int n = 1 << l;
int m = n >> 1;
int *ww = inverse ? wv[l] : wu[l];
int i, j;
/* solve for even and odd degrees */
/* P(x) = P_even(x) + x * P_odd(x) */
/* where P_even(x) is the terms with even degree and */
/* where P_odd(x) is the terms with odd degree and */
ntt_(aa, l - 1, inverse);
ntt_(aa + m, l - 1, inverse);
/* now we make the point value form */
for (i = 0; (j = i + m) < n; i++) {
/* a is even degree */
/* b is odd degree, multiply by root^i */
/* because we need to multiply back the part from */
/* splitting P(x) into P_even(x) + x * P_odd(x) with x = root^i */
int a = aa[i];
int b = (long long) aa[j] * ww[i] % MD;
/* even part is all positive for all x of x ^ y */
/* odd part is positive for x ^ y such that x is positive (first case, even index) */
/* otherwise negative for negative x (second case, odd index) */
if ((aa[i] = a + b) >= MD)
aa[i] -= MD;
if ((aa[j] = a - b) < 0)
aa[j] += MD;
}
}
}
void ntt(int *aa, int l, int inverse) {
int n_ = 1 << l, i, j;
/* reverse the bits for each element so that */
/* in the FFT we don't have to split the even/odd indexes */
/* as it becomes into two ranges: [l, m) and [m, r) */
for (i = 0, j = 1; j < n_; j++) {
int b;
int tmp;
for (b = n_ >> 1; (i ^= b) < b; b >>= 1)
;
if (i < j)
tmp = aa[i], aa[i] = aa[j], aa[j] = tmp;
}
ntt_(aa, l, inverse);
}
void mult(int *aa, int n, int *bb, int m, int *out) {
static int aa_[N_], bb_[N_];
int l, n_, i, v;
/* enlarge size so that it's a power of 2 */
l = 0;
while (1 << l <= n - 1 + m - 1)
l++;
n_ = 1 << l;
memcpy(aa_, aa, n * sizeof *aa), memset(aa_ + n, 0, (n_ - n) * sizeof *aa_);
memcpy(bb_, bb, m * sizeof *bb), memset(bb_ + m, 0, (n_ - m) * sizeof *bb_);
/* FFT: convert coefficient form to point value form */
ntt(aa_, l, 0), ntt(bb_, l, 0);
/* combine point value forms */
for (i = 0; i < n_; i++)
out[i] = (long long) aa_[i] * bb_[i] % MD;
/* Inverse FFT: convert point value form to coefficient form */
ntt(out, l, 1);
v = power(n_, MD - 2);
for (i = 0; i < n_; i++)
out[i] = (long long) out[i] * v % MD;
}
int main() {
static int aa[N], bb[N], out[N_];
int n, m, i;
init();
scanf("%d%d", &n, &m), n++, m++;
for (i = 0; i < n; i++)
scanf("%d", &aa[i]);
for (i = 0; i < m; i++)
scanf("%d", &bb[i]);
mult(aa, n, bb, m, out);
for (i = 0; i < n + m - 1; i++)
printf("%d ", out[i]);
printf("\n");
return 0;
}
I2luY2x1ZGUgPGJpdHMvc3RkYysrLmg+CnVzaW5nIG5hbWVzcGFjZSBzdGQ7CgojZGVmaW5lIE4JMTAwMDAxCiNkZWZpbmUgTAk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