Problem:
Score : 100 points

Problem Statement

You are given two integer arrays a_0, a_1, ..., a_{N - 1} and b_0, b_1, ..., b_{M - 1}. Calculate the array c_0, c_1, ..., c_{(N - 1) + (M - 1)}, defined by c_i = \sum_{j = 0}^i a_j b_{i - j} \bmod 998244353.

Constraints

1 \leq N, M \leq 524288

0 \leq a_i, b_i < 998244353

All values in Input are integer.

Input

Input is given from Standard Input in the following format:

N M
a_0 a_1 ... a_{N-1}
b_0 b_1 ... b_{M-1}

Output

Print the answer in the following format:

c_0 c_1 ... c_{(N - 1) + (M - 1)}

Sample Input 1

4 5
1 2 3 4
5 6 7 8 9

Sample Output 1

5 16 34 60 70 70 59 36

Sample Input 2

1 1
10000000
10000000

Sample Output 2

871938225

Solution in PyPy3 (7.3.0) (judge verdict: Wrong Answer)

def FFT(A):
    from math import sin,cos,exp,pi

    n=len(A)
    m=1
    while m<n:
        m<<=1
    w=complex(cos(2*pi/m),sin(2*pi/m))

    def fft(x):
        t=len(x)
        if t==1:
            return x

        y=[0]*(t>>1)
        z=[0]*(t>>1)

        w=complex(cos(2*pi/t),sin(2*pi/t))
        for k in range(t//2):
            y[k]=x[k]+x[k+t//2]
            z[k]=(x[k]-x[k+t//2])*(w**k)

        y=fft(y)
        z=fft(z)

        x=[0]*t
        for k in range(t>>1):
            x[2*k]=y[k]
            x[2*k+1]=z[k]

        return x

    B=A+[0]*(m-n)
    return fft(B)

def Inverse_FFT(A):
    for i in range(len(A)):
        if isinstance(A[i],complex):
            A[i]=A[i].conjugate()

    G=FFT(A)
    for i in range(len(G)):
        if isinstance(G[i],complex):
            G[i]=G[i].conjugate()

    return [a/len(G) for a in G]

def Convolution(A,B,Mod=None):
    from math import floor

    N=len(A);M=len(B)
    if N==0 or M==0:
        return []

    z=1
    while z<N+M-1:
        z<<=1

    A=A+[0]*(z-N)
    B=B+[0]*(z-M)

    P=FFT(A)
    Q=FFT(B)

    R=[0]*z
    for i in range(z):
        R[i]=P[i]*Q[i]
    R=Inverse_FFT(R)
    return  [floor(a.real+1/2) for a in R]
#================================================
N,M=map(int,input().split())
Mod=998244353
A=list(map(int,input().split()))
B=list(map(int,input().split()))

C=Convolution(A,B)
print(" ".join(map(lambda x:str(x%Mod),C)))