QOJ.ac

QOJ

时间限制: 5 s 内存限制: 512 MB 总分: 100

#13267. XOR Sum

统计

Given $m$ and a sequence $a_1, a_2, \dots, a_m$, let $R = 2^{a_1} + 2^{a_2} + \dots + 2^{a_m}$, where it is guaranteed that $a_1 < a_2 < \dots < a_m$.

Given $c$ and $c$ integers $A_1, A_2, \dots, A_c$, let the set $A = \{1, A_1, A_2, \dots, A_c\}$.

You need to choose $n$ integers in the range $[0, R)$ such that:

  • Their XOR sum is $0$.
  • For every integer that appears in the selection, its frequency of occurrence is in $A$.

Two schemes are considered different if and only if there exists at least one integer whose frequency of occurrence is different.

Calculate the number of such schemes modulo $998244353$.

Input

The first line contains three integers $n, m, c$.

The second line contains $c$ positive integers $A_1, A_2, \dots, A_c$. If $c=0$, this line does not exist.

The $[c > 0]+1$-th line contains $m$ non-negative integers $a_1, a_2, \dots, a_m$.

Output

A single line containing a non-negative integer representing the answer.

Examples

Input 1

4 3 0
1 3 5

Output 1

1978

Input 2

3 5 1
2
0 1 2 5 6

Output 2

1494

Input 3

2333 2 5
2 3 4 5 6
114514 1919810

Output 3

264224065

Constraints

For $100\%$ of the data, $1 \le n, m \le 10^5$, $0 \le c \le 10$, $0 \le a_1 < a_2 < \dots < a_m \le 10^{18}$, $1 < A_1 < A_2 < \dots < A_c \le n$.

The constraints for each test case are as follows:

Test Case ID Special Constraints
$1$ $n \le 3$, $a_m \le 6$
$2 \sim 3$ $c \le 0$, $m \le 1$
$4 \sim 6$ $c \le 0$, $n \le 7$, $m \le 100$
$7 \sim 9$ $c \le 0$, $n \le 10$, $m \le 100$
$10 \sim 12$ $c \le 0$, $n, m \le 100$
$13 \sim 15$ $c \le 0$, $n, m \le 5000$
$16 \sim 18$ $c \le 0$
$19 \sim 20$ None

Editorials

IDTypeStatusTitlePosted ByLast UpdatedActions
EditorialOpen Official EditorialQingyu- Download

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.