Tree Depth#10295

Tree Depth

1 second
128 megabytes
Very easy

For the new year, Farmer John decided to give his cows a festive binary search tree (BST)!

To generate the BST, FJ starts with a permutation a = \{a_1, a_2, \ldots, a_n\} of the integers to , where n \le 300. He then runs the following pseudocode with arguments and .

generate(l,r):
  if l > r, return empty subtree;
  x = argmin_{l <= i <= r} a_i; // index of min a_i in {a_l,...,a_r}
  return a BST with x as the root, 
    generate(l,x-1) as the left subtree,
    generate(x+1,r) as the right subtree;

For example, the permutation \{3, 2, 5, 1, 4\} generates the following BST:

    4
   / \
  2   5
 / \ 
1   3

Let d_i(a) denote the depth of node in the tree corresponding to , meaning the number of nodes on the path from a_i to the root. In the above example, d_4(a) = 1, d_2(a) = d_5(a) = 2, and d_1(a) = d_3(a) = 3.

The number of inversions of is equal to the number of pairs of integers such that 1 \le i < j \le n and a_i > a_j. The cows know that the that FJ will use to generate the BST has exactly inversions (0 \le k \le n \cdot (n - 1) / 2). Over all satisfying this condition, compute the remainder when \sum_a d_i(a) is divided by for each 1 \le i \le n.

Input

The only line consists of three space-separated integers , and . will be a prime number in the range [10^8, 10^9 + 9].

Output

Print integers denoting \sum_a d_i(a) \pmod{m} for each 1 \le i \le n.

Examples

Example 1

Loading
Loading

Example 2

Loading
Loading

Note

Example 1: the only permutation is a = \{1, 2, 3\}.

Example 2: the two permutations are a = \{1, 3, 2\} and a = \{2, 1, 3\}.