atcoder#ARC139D. [ARC139D] Priority Queue 2

[ARC139D] Priority Queue 2

Score : 700700 points

Problem Statement

You are given a multiset of integers with NN elements: A={A1,A2,...,AN}A=\lbrace A_1,A_2,...,A_N \rbrace. It is guaranteed that every element of AA is between 11 and MM (inclusive).

Let us repeat the following operation KK times.

  • Choose an integer between 11 and MM (inclusive) and add it to AA. Then, delete the XX-th smallest value in AA.

Here, the XX-th smallest value in AA is the XX-th value from the front in the sequence of the elements of AA sorted in non-decreasing order.

There are MKM^K ways to choose an integer KK times between 11 and MM. Assume that, for each of these ways, we have found the sum of the elements of AA after the operations with the corresponding choices. Find the sum, modulo 998244353998244353, of the MKM^K values computed.

Constraints

  • 1N,M,K20001 \le N,M,K \le 2000
  • 1XN+11 \le X \le N+1
  • 1AiM1 \le A_i \le M
  • All values in input are integers.

Input

Input is given from Standard Input in the following format:

NN MM KK XX

A1A_1 A2A_2 \dots ANA_N

Output

Print the answer.

2 4 2 1
1 3
99

We start with A={1,3}A=\{1,3\}. Here is an example of how we do the operations.

  • Add 44 to AA, making A={1,3,4}A=\{1,3,4\}. Then, delete the 11-st smallest value, making A={3,4}A=\{3,4\}.
  • Add 33 to AA, making A={3,3,4}A=\{3,3,4\}. Then, delete the 11-st smallest value, making A={3,4}A=\{3,4\}.

In this case, the sum of the elements of AA after the operations is 3+4=73+4=7.

5 9 6 3
3 7 1 9 9
15411789