mod = 998244353 R = 3 Rinv = 332748118 W = [pow(R, (mod-1)>>i, mod) for i in range(24)] Winv = [pow(Rinv, (mod-1)>>i, mod) for i in range(24)] def fft(k, f): for l in range(k, 0, -1): d = 1<=k>=0 else 0 q2=[[]] l=1<<(len(bin(K+1))-2) for j in range(1,K+1): q3=[1]+[fb[k] for k in range(1,j+1)] q3+=[0]*(l-len(q3)) q3=FPSlog(q3) q2+=[q3] g=[0]*(K+1) for i in range(1,K+1): if K%i==0: c=[0]*(K+1) for v in a: c[v//(K//i)]+=1 l=1<<(len(bin(i+1))-2) q=[0]*l for j in range(1,i+1): if c[j]>0: for k in range(l): if k