import sys from collections import deque, Counter input = lambda: sys.stdin.readline().rstrip() ii = lambda: int(input()) mi = lambda: map(int, input().split()) li = lambda: list(mi()) inf = 2 ** 63 - 1 mod = 998244353 import random n, m, k = mi() a = li() MAXI = k valuetop = [] valuebottom = [] dptop = [] dpbottom = [] X = [0] * MAXI X[0] = 1 dptop.append(X) dpbottom.append(X) def push(x): valuebottom.append(x) ndp = [0] * MAXI for v in range(MAXI): ndp[(v+x)%MAXI] += dpbottom[-1][v] ndp[v] += dpbottom[-1][v] ndp[(v+x)%MAXI] %= mod ndp[v] %= mod dpbottom.append(ndp) def pop(): if not valuetop: valuebottom.reverse() for x in valuebottom: ndp = [0] * MAXI for v in range(MAXI): ndp[(v+x)%MAXI] += dptop[-1][v] ndp[v] += dptop[-1][v] ndp[(v+x)%MAXI] %= mod ndp[v] %= mod dptop.append(ndp) valuetop.append(x) while valuebottom: valuebottom.pop() while len(dpbottom) > 1: dpbottom.pop() dptop.pop() valuetop.pop() def fold(): ans = 0 for v in range(MAXI): ans += dptop[-1][v] * dpbottom[-1][(MAXI-v) % MAXI] ans %= mod return ans for i in range(m): push(a[i]) ans = [] ans.append(fold()) for i in range(m, n): pop() push(a[i]) ans.append(fold()) for v in ans: print((v-1) % mod)