ROOT = 3

MOD = 998244353

pn = [pow(ROOT,(MOD-1)>>i,MOD) for i in range(30)]



def ntt_rec(a,n):

    if n==0:

        return a[:]

    if n==1:

        return [a[0]+a[1],a[0]-a[1]]



    b = ntt_rec(a[::2],n-1)

    c = ntt_rec(a[1::2],n-1)

    

    N = 1<<(n-1)

    res = [0]*(N*2)

    w_N = 1

    for k in range(N):

        res[k]   = (b[k] + w_N*c[k])%MOD

        res[k+N] = (b[k] - w_N*c[k])%MOD

        w_N = w_N*pn[n]%MOD

    return res



def intt_rec(a,n):

    res = ntt_rec(a[0:1]+a[1:][::-1],n)

    inv = pow(1<<n,MOD-2,MOD)

    for i in range(1<<n):

        res[i] = res[i]*inv%MOD

    return res





def convolution(a,b):

    deg = len(a) + len(b) - 1

    n = 0

    N = 1

    while deg*2 >= N:

        n += 1

        N <<= 1

    

    a += [0]*(N-len(a))

    b += [0]*(N-len(b))

    

    #print(ntt_rec(a,n))

    return intt_rec([ai*bi%MOD for ai,bi in zip(ntt_rec(a,n),ntt_rec(b,n))],n)



n,m = list(map(int,input().split()))

a = list(map(int,input().split()))

b = list(map(int,input().split()))

#*a, = [1]*10**5

#*b, = [1]*10**5

L = len(a)+len(b)

c = convolution(a,b)

print((*c[:L-1]))

ROOT = 3

MOD = 998244353

roots  = [pow(ROOT,(MOD-1)>>i,MOD) for i in range(24)] # 1 の 2^i 乗根

iroots = [pow(x,MOD-2,MOD) for x in roots] # 1 の 2^i 乗根の逆元



def untt(a,n):

    for i in range(n):

        m = 1<<(n-i-1)

        for s in range(1<<i):

            w_N = 1

            s *= m*2

            for p in range(m):

                a[s+p], a[s+p+m] = (a[s+p]+a[s+p+m])%MOD, (a[s+p]-a[s+p+m])*w_N%MOD

                w_N = w_N*roots[n-i]%MOD



def iuntt(a,n):

    for i in range(n):

        m = 1<<i

        for s in range(1<<(n-i-1)):

            w_N = 1

            s *= m*2

            for p in range(m):

                a[s+p], a[s+p+m] = (a[s+p]+a[s+p+m]*w_N)%MOD, (a[s+p]-a[s+p+m]*w_N)%MOD

                w_N = w_N*iroots[i+1]%MOD

            

    inv = pow((MOD+1)//2,n,MOD)

    for i in range(1<<n):

        a[i] = a[i]*inv%MOD



def convolution(a,b):

    deg = len(a) + len(b) - 2

    n = deg.bit_length()

    N = 1<<n

    a += [0]*(N-len(a))

    b += [0]*(N-len(b))

    untt(a,n)

    untt(b,n)

    for i in range(N):

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

    iuntt(a,n)

    return a[:deg+1]



n,m = list(map(int,input().split()))

a = list(map(int,input().split()))

b = list(map(int,input().split()))

c = convolution(a,b)

print((*c))
ROOT = 3
MOD = 998244353
pn = [pow(ROOT, (MOD - 1) >> i, MOD) for i in range(30)]


def ntt_rec(a, n):
    if n == 0:
        return a[:]
    if n == 1:
        return [a[0] + a[1], a[0] - a[1]]
    b = ntt_rec(a[::2], n - 1)
    c = ntt_rec(a[1::2], n - 1)
    N = 1 << (n - 1)
    res = [0] * (N * 2)
    w_N = 1
    for k in range(N):
        res[k] = (b[k] + w_N * c[k]) % MOD
        res[k + N] = (b[k] - w_N * c[k]) % MOD
        w_N = w_N * pn[n] % MOD
    return res


def intt_rec(a, n):
    res = ntt_rec(a[0:1] + a[1:][::-1], n)
    inv = pow(1 << n, MOD - 2, MOD)
    for i in range(1 << n):
        res[i] = res[i] * inv % MOD
    return res


def convolution(a, b):
    deg = len(a) + len(b) - 1
    n = 0
    N = 1
    while deg * 2 >= N:
        n += 1
        N <<= 1
    a += [0] * (N - len(a))
    b += [0] * (N - len(b))
    # print(ntt_rec(a,n))
    return intt_rec([ai * bi % MOD for ai, bi in zip(ntt_rec(a, n), ntt_rec(b, n))], n)


n, m = list(map(int, input().split()))
a = list(map(int, input().split()))
b = list(map(int, input().split()))
# *a, = [1]*10**5
# *b, = [1]*10**5
L = len(a) + len(b)
c = convolution(a, b)
print((*c[: L - 1]))

ROOT = 3
MOD = 998244353
roots = [pow(ROOT, (MOD - 1) >> i, MOD) for i in range(24)]  # 1 の 2^i 乗根
iroots = [pow(x, MOD - 2, MOD) for x in roots]  # 1 の 2^i 乗根の逆元


def untt(a, n):
    for i in range(n):
        m = 1 << (n - i - 1)
        for s in range(1 << i):
            w_N = 1
            s *= m * 2
            for p in range(m):
                a[s + p], a[s + p + m] = (a[s + p] + a[s + p + m]) % MOD, (
                    a[s + p] - a[s + p + m]
                ) * w_N % MOD
                w_N = w_N * roots[n - i] % MOD


def iuntt(a, n):
    for i in range(n):
        m = 1 << i
        for s in range(1 << (n - i - 1)):
            w_N = 1
            s *= m * 2
            for p in range(m):
                a[s + p], a[s + p + m] = (a[s + p] + a[s + p + m] * w_N) % MOD, (
                    a[s + p] - a[s + p + m] * w_N
                ) % MOD
                w_N = w_N * iroots[i + 1] % MOD
    inv = pow((MOD + 1) // 2, n, MOD)
    for i in range(1 << n):
        a[i] = a[i] * inv % MOD


def convolution(a, b):
    deg = len(a) + len(b) - 2
    n = deg.bit_length()
    N = 1 << n
    a += [0] * (N - len(a))
    b += [0] * (N - len(b))
    untt(a, n)
    untt(b, n)
    for i in range(N):
        a[i] = a[i] * b[i] % MOD
    iuntt(a, n)
    return a[: deg + 1]


n, m = list(map(int, input().split()))
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = convolution(a, b)
print((*c))

-pn = [pow(ROOT, (MOD - 1) >> i, MOD) for i in range(30)] +roots = [pow(ROOT, (MOD - 1) >> i, MOD) for i in range(24)]  # 1 の 2^i 乗根 +iroots = [pow(x, MOD - 2, MOD) for x in roots]  # 1 の 2^i 乗根の逆元 -def ntt_rec(a, n): -    if n == 0: -        return a[:] -    if n == 1: -        return [a[0] + a[1], a[0] - a[1]] -    b = ntt_rec(a[::2], n - 1) -    c = ntt_rec(a[1::2], n - 1) -    N = 1 << (n - 1) -    res = [0] * (N * 2) -    w_N = 1 -    for k in range(N): -        res[k] = (b[k] + w_N * c[k]) % MOD -        res[k + N] = (b[k] - w_N * c[k]) % MOD -        w_N = w_N * pn[n] % MOD -    return res +def untt(a, n): +    for i in range(n): +        m = 1 << (n - i - 1) +        for s in range(1 << i): +            w_N = 1 +            s *= m * 2 +            for p in range(m): +                a[s + p], a[s + p + m] = (a[s + p] + a[s + p + m]) % MOD, ( +                    a[s + p] - a[s + p + m] +                ) * w_N % MOD +                w_N = w_N * roots[n - i] % MOD -def intt_rec(a, n): -    res = ntt_rec(a[0:1] + a[1:][::-1], n) -    inv = pow(1 << n, MOD - 2, MOD) +def iuntt(a, n): +    for i in range(n): +        m = 1 << i +        for s in range(1 << (n - i - 1)): +            w_N = 1 +            s *= m * 2 +            for p in range(m): +                a[s + p], a[s + p + m] = (a[s + p] + a[s + p + m] * w_N) % MOD, ( +                    a[s + p] - a[s + p + m] * w_N +                ) % MOD +                w_N = w_N * iroots[i + 1] % MOD +    inv = pow((MOD + 1) // 2, n, MOD) -        res[i] = res[i] * inv % MOD -    return res +        a[i] = a[i] * inv % MOD -    deg = len(a) + len(b) - 1 -    n = 0 -    N = 1 -    while deg * 2 >= N: -        n += 1 -        N <<= 1 +    deg = len(a) + len(b) - 2 +    n = deg.bit_length() +    N = 1 << n -    # print(ntt_rec(a,n)) -    return intt_rec([ai * bi % MOD for ai, bi in zip(ntt_rec(a, n), ntt_rec(b, n))], n) +    untt(a, n) +    untt(b, n) +    for i in range(N): +        a[i] = a[i] * b[i] % MOD +    iuntt(a, n) +    return a[: deg + 1] -# *a, = [1]*10**5 -# *b, = [1]*10**5 -L = len(a) + len(b) -print((*c[: L - 1])) +print((*c))