QOJ.ac

QOJ

時間限制: 1 s 記憶體限制: 2048 MB 總分: 100

#10281. Against Brainwaves

统计

You and a friend once tried to solve a problem together. A solution to a problem can be viewed as $n$ properties numbered from $1$ to $n$. Each property can be represented by a characteristic value $p_i$. A larger $p_i$ indicates that the property is more "intellectual," while a smaller $p_i$ indicates that the property is more "routine." Since each property is distinct, $p$ forms a permutation of length $n$.

He is a master of Japanese-style problems. After thinking, he came up with $k$ properties, and the subsequence $S_0$ formed by these $k$ properties is exactly the lexicographically largest subsequence of length $k$ in $p$.

You are a master of Chinese-style problems. After thinking, you also came up with $k$ properties, and the subsequence $S_1$ formed by these $k$ properties is exactly the lexicographically smallest subsequence of length $k$ in $p$.

You both listed the properties you thought of. You recorded a longest common subsequence between $S_0$ and $S_1$ on a piece of paper.

Then the bell rang, and you went to eat together.

A long time has passed, and you have long since gone your separate ways. One day, while tidying up your belongings, you found this piece of paper again. You remembered that unsolved problem. You want to know how many possible solutions to that problem could have resulted in the appearance of this piece of paper.

The answer should be taken modulo $998244353$.

Input

The input is read from standard input. The first line contains three positive integers $n, k, m$ ($2 \le m \le k \le n \le 400$), representing the total number of properties, the number of properties you and he found, and the length of the longest common subsequence, respectively. The second line contains $m$ positive integers $S_1, S_2, \dots, S_m$ ($1 \le S_i \le n$), representing the longest common subsequence recorded on the paper.

Output

Output to standard output. Output a single integer representing the number of permutations satisfying the requirements, modulo $998244353$.

Examples

Input 1

5 3 2
2 3

Output 1

4

Note 1

The following 4 permutations satisfy the requirements: $1, 4, 5, 2, 3$ $4, 1, 5, 2, 3$ $4, 5, 1, 2, 3$ $4, 5, 2, 1, 3$

Input 2

6 4 2
2 3

Output 2

10

Note 2

The following 10 permutations satisfy the requirements: $1, 4, 5, 6, 2, 3$ $1, 4, 6, 5, 2, 3$ $1, 5, 4, 6, 2, 3$ $1, 6, 4, 5, 2, 3$ $4, 6, 5, 1, 2, 3$ $4, 6, 5, 2, 1, 3$ $5, 1, 4, 6, 2, 3$ $6, 1, 4, 5, 2, 3$ $6, 4, 5, 1, 2, 3$ $6, 4, 5, 2, 1, 3$

Input 3

2 2 2
1 1

Output 3

0

Note 3

Clearly, there are no permutations that satisfy the requirements.

Input 4

11 5 2
6 4

Output 4

198198

Input 5

20 10 5
13 17 10 6 5

Output 5

392592366

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.