#ARC145F. [ARC145F] Modulo Sum of Increasing Sequences

[ARC145F] Modulo Sum of Increasing Sequences

Score : 12001200 points

Problem Statement

Find the number, modulo 998244353998244353, of non-decreasing sequences A=(A1,A2,,AN)A=(A_1,A_2,\ldots,A_N) of length NN consisting of integers between 00 and MM (inclusive) that satisfy the following, for each K=0,1,,MOD1K=0,1,\ldots,\mathrm{MOD}-1:

  • the sum of the elements in AA is congruent to KK modulo MOD\mathrm{MOD}.
What is a non-decreasing sequence? $$B$$$$B_i \leq B_{i+1}$$$$1 \le i \le |B| - 1$$$$|B|$$$$B $$

Constraints

  • 1N,M1061 \leq N ,M\leq 10^6
  • 1MOD5001\leq \mathrm{MOD}\leq 500
  • All values in input are integers.

Input

Input is given from Standard Input in the following format:

NN MM MOD\mathrm{MOD}

Output

For each K=0,1,,MOD1K=0,1,\ldots,\mathrm{MOD}-1, print the number, modulo 998244353998244353, of sequences that satisfy the condition.

2 2 4
2 1 2 1

There are 66 non-decreasing sequences of length 22 consisting of integers between 00 and 22: (0,0),(0,1),(0,2),(1,1),(1,2),(2,2)(0, 0), (0, 1),(0,2), (1,1),(1,2),(2,2). Here, we have:

  • 22 sequences whose sums are congruent to 00 modulo 44: (0,0),(2,2)(0,0),(2,2);
  • 11 sequence whose sum is congruent to 11 modulo 44: (0,1)(0,1);
  • 22 sequences whose sums are congruent to 22 modulo 44: (0,2),(1,1)(0,2),(1,1);
  • 11 sequence whose sum is congruent to 33 modulo 44: (1,2)(1,2).
3 45 3
5776 5760 5760
1000000 1000000 6
340418986 783857865 191848859 783857865 340418986 635287738

Print the counts modulo 998244353998244353.