def fft(f, n, w, p, g):

    d = n // 2

    v = w

    while d >= 1:

        u = 1

        for i in range(d):

            for j in range(i, n, 2*d):

                f[j], f[j+d] = (f[j] + f[j+d]) % p, u * (f[j] - f[j+d]) % p

            u = u * v % p

        v = v * v % p

        d //= 2

def ifft(f, n, invw, p, g):

    d = 1

    while d < n:

        v = pow(invw, n // (2 * d), p)

        u = 1

        for i in range(d):

            for j in range(i, n, 2*d):

                f[j+d] *= u

                f[j], f[j+d] = (f[j] + f[j+d]) % p, (f[j] - f[j+d]) % p

            u = u * v % p

        d *= 2

def convolve(a, b):

    p, g = 998244353, 3

    n0, n1 = len(a), len(b)

    n = 1 << (max(n0, n1) - 1).bit_length() + 1

    a = a + [0] * (n-n0)

    b = b + [0] * (n-n1)

    w = pow(g, (p - 1) // n, p)

    invw = pow(w, p-2, p)

    fft(a, n, w, p, g), fft(b, n, w, p, g)

    for i in range(n):

        a[i] = a[i] * b[i] % p

    ifft(a, n, invw, p, g)

    invn = pow(n, p - 2, p)

    return [a[i] * invn % p for i in range(n0 + n1 - 1)]



N, M = list(map(int, input().split()))

A = [int(a) for a in input().split()]

B = [int(a) for a in input().split()]

print((*convolve(A, B)))

p, g = 998244353, 3

def convolve(a, b):

    def fft(f):

        d = n // 2

        v = w

        while d >= 1:

            u = 1

            for i in range(d):

                for j in range(i, n, 2*d):

                    f[j], f[j+d] = (f[j] + f[j+d]) % p, u * (f[j] - f[j+d]) % p

                u = u * v % p

            v = v * v % p

            d //= 2

 

    def ifft(f):

        d = 1

        while d < n:

            v = pow(invw, n // (2 * d), p)

            u = 1

            for i in range(d):

                for j in range(i, n, 2*d):

                    f[j+d] *= u

                    f[j], f[j+d] = (f[j] + f[j+d]) % p, (f[j] - f[j+d]) % p

                u = u * v % p

            d *= 2

 

    n0, n1 = len(a), len(b)

    n = 1 << (max(n0, n1) - 1).bit_length() + 1

    a = a + [0] * (n-n0)

    b = b + [0] * (n-n1)

    w = pow(g, (p - 1) // n, p)

    invw = pow(w, p-2, p)

    fft(a), fft(b)

    for i in range(n):

        a[i] = a[i] * b[i] % p

    ifft(a)

    invn = pow(n, p - 2, p)

    return [a[i] * invn % p for i in range(n0 + n1 - 1)]



N, M = list(map(int, input().split()))

A = [int(a) for a in input().split()]

B = [int(a) for a in input().split()]

print((*convolve(A, B)))

def fft(f, n, w, p, g):
    d = n // 2
    v = w
    while d >= 1:
        u = 1
        for i in range(d):
            for j in range(i, n, 2 * d):
                f[j], f[j + d] = (f[j] + f[j + d]) % p, u * (f[j] - f[j + d]) % p
            u = u * v % p
        v = v * v % p
        d //= 2


def ifft(f, n, invw, p, g):
    d = 1
    while d < n:
        v = pow(invw, n // (2 * d), p)
        u = 1
        for i in range(d):
            for j in range(i, n, 2 * d):
                f[j + d] *= u
                f[j], f[j + d] = (f[j] + f[j + d]) % p, (f[j] - f[j + d]) % p
            u = u * v % p
        d *= 2


def convolve(a, b):
    p, g = 998244353, 3
    n0, n1 = len(a), len(b)
    n = 1 << (max(n0, n1) - 1).bit_length() + 1
    a = a + [0] * (n - n0)
    b = b + [0] * (n - n1)
    w = pow(g, (p - 1) // n, p)
    invw = pow(w, p - 2, p)
    fft(a, n, w, p, g), fft(b, n, w, p, g)
    for i in range(n):
        a[i] = a[i] * b[i] % p
    ifft(a, n, invw, p, g)
    invn = pow(n, p - 2, p)
    return [a[i] * invn % p for i in range(n0 + n1 - 1)]


N, M = list(map(int, input().split()))
A = [int(a) for a in input().split()]
B = [int(a) for a in input().split()]
print((*convolve(A, B)))

p, g = 998244353, 3


def convolve(a, b):
    def fft(f):
        d = n // 2
        v = w
        while d >= 1:
            u = 1
            for i in range(d):
                for j in range(i, n, 2 * d):
                    f[j], f[j + d] = (f[j] + f[j + d]) % p, u * (f[j] - f[j + d]) % p
                u = u * v % p
            v = v * v % p
            d //= 2

    def ifft(f):
        d = 1
        while d < n:
            v = pow(invw, n // (2 * d), p)
            u = 1
            for i in range(d):
                for j in range(i, n, 2 * d):
                    f[j + d] *= u
                    f[j], f[j + d] = (f[j] + f[j + d]) % p, (f[j] - f[j + d]) % p
                u = u * v % p
            d *= 2

    n0, n1 = len(a), len(b)
    n = 1 << (max(n0, n1) - 1).bit_length() + 1
    a = a + [0] * (n - n0)
    b = b + [0] * (n - n1)
    w = pow(g, (p - 1) // n, p)
    invw = pow(w, p - 2, p)
    fft(a), fft(b)
    for i in range(n):
        a[i] = a[i] * b[i] % p
    ifft(a)
    invn = pow(n, p - 2, p)
    return [a[i] * invn % p for i in range(n0 + n1 - 1)]


N, M = list(map(int, input().split()))
A = [int(a) for a in input().split()]
B = [int(a) for a in input().split()]
print((*convolve(A, B)))

-def fft(f, n, w, p, g): -    d = n // 2 -    v = w -    while d >= 1: -        u = 1 -        for i in range(d): -            for j in range(i, n, 2 * d): -                f[j], f[j + d] = (f[j] + f[j + d]) % p, u * (f[j] - f[j + d]) % p -            u = u * v % p -        v = v * v % p -        d //= 2 - - -def ifft(f, n, invw, p, g): -    d = 1 -    while d < n: -        v = pow(invw, n // (2 * d), p) -        u = 1 -        for i in range(d): -            for j in range(i, n, 2 * d): -                f[j + d] *= u -                f[j], f[j + d] = (f[j] + f[j + d]) % p, (f[j] - f[j + d]) % p -            u = u * v % p -        d *= 2 +p, g = 998244353, 3 -    p, g = 998244353, 3 +    def fft(f): +        d = n // 2 +        v = w +        while d >= 1: +            u = 1 +            for i in range(d): +                for j in range(i, n, 2 * d): +                    f[j], f[j + d] = (f[j] + f[j + d]) % p, u * (f[j] - f[j + d]) % p +                u = u * v % p +            v = v * v % p +            d //= 2 + +    def ifft(f): +        d = 1 +        while d < n: +            v = pow(invw, n // (2 * d), p) +            u = 1 +            for i in range(d): +                for j in range(i, n, 2 * d): +                    f[j + d] *= u +                    f[j], f[j + d] = (f[j] + f[j + d]) % p, (f[j] - f[j + d]) % p +                u = u * v % p +            d *= 2 + -    fft(a, n, w, p, g), fft(b, n, w, p, g) +    fft(a), fft(b) -    ifft(a, n, invw, p, g) +    ifft(a)