import numpy as np from numpy.core.numeric import convolve class NTT: def __init__(self, D: int, MOD: int, root: int) -> None: self.md = MOD self.w = np.array([1], np.int64) self.iw = np.array([1], np.int64) while len(self.w) < 1 << (D - 1): dw = pow(root, (self.md - 1) // (len(self.w) * 4), self.md) dwinv = pow(dw, -1, self.md) self.w = np.r_[self.w, self.w * dw] % self.md self.iw = np.r_[self.iw, self.iw * dwinv] % self.md def ntt(self, mat: np.ndarray): in_shape = mat.shape n = in_shape[-1] m = n // 2 while m: mat = mat.reshape(-1, n // (m * 2), 2, m) w_use = self.w[:n // (m * 2)].reshape(1, -1, 1) y = mat[:, :, 1] * w_use % self.md mat = np.stack((mat[:, :, 0] + y, mat[:, :, 0] + self.md - y), 2) % self.md m //= 2 return mat.reshape(in_shape) def intt(self, mat: np.ndarray): in_shape = mat.shape n = in_shape[-1] m = 1 while m < n: mat = mat.reshape(-1, n // (m * 2), 2, m) iw_use = self.iw[:n // (m * 2)].reshape(1, -1, 1) mat = np.stack((mat[:, :, 0] + mat[:, :, 1], (mat[:, :, 0] + self.md - mat[:, :, 1]) * iw_use), 2) % self.md m *= 2 n_inv = pow(n, -1, self.md) return mat.reshape(in_shape) * n_inv % self.md def convolve(self, v1: np.ndarray, v2: np.ndarray) -> np.ndarray: v1 = v1.copy() v2 = v2.copy() n1, n2 = len(v1), len(v2) nret = n1 + n2 - 1 nfft = 1 while nfft < nret: nfft <<= 1 v1.resize(nfft) v2.resize(nfft) v1 = self.ntt(v1) v2 = self.ntt(v2) vret = v1 * v2 % md vret = self.intt(vret) vret.resize(nret) return vret md = 998244353 convolver = NTT(18, md, 3) N = int(input()) A = np.array(list(map(int, input().split())), dtype=np.int64) polys = [None] * (N * 2) p10 = 10 for i in range(N - 1): polys[i] = np.array([1, p10], dtype=np.int64) p10 = p10 * p10 % md l, r = 0, N - 1 while l + 1 < r: polys[r] = convolver.convolve(polys[l], polys[l + 1]) polys[l] = None polys[l + 1] = None r += 1 l += 2 vs = convolver.convolve(polys[l], A) ret = np.zeros(N, dtype=np.int64) for i, v in enumerate(vs): ret[(i + 1) % N] += v ret %= md print(*list(ret), sep='\n')