#P1728G. Illumination

    ID: 818 Type: RemoteJudge 8000ms 512MiB Tried: 0 Accepted: 0 Difficulty: 10 Uploaded By: Tags>binary searchbitmasksbrute forcecombinatoricsdpmathtwo pointers*2700

Illumination

Description

Consider a segment [0,d][0, d] of the coordinate line. There are nn lanterns and mm points of interest in this segment.

For each lantern, you can choose its power — an integer between 00 and dd (inclusive). A lantern with coordinate xx illuminates the point of interest with coordinate yy if xy|x - y| is less than or equal to the power of the lantern.

A way to choose the power values for all lanterns is considered valid if every point of interest is illuminated by at least one lantern.

You have to process qq queries. Each query is represented by one integer fif_i. To answer the ii-th query, you have to:

  • add a lantern on coordinate fif_i;
  • calculate the number of valid ways to assign power values to all lanterns, and print it modulo 998244353998244353;
  • remove the lantern you just added.

The first line contains three integers dd, nn and mm (4d31054 \le d \le 3 \cdot 10^5; 1n21051 \le n \le 2 \cdot 10^5; 1m161 \le m \le 16) — the size of the segment, the number of lanterns and the number of points of interest, respectively.

The second line contains nn integers l1,l2,,lnl_1, l_2, \dots, l_n (1lid11 \le l_i \le d - 1), where lil_i is the coordinate of the ii-th lantern.

The third line contains mm integers p1,p2,,pmp_1, p_2, \dots, p_m (1pid11 \le p_i \le d - 1), where pip_i is the coordinate of the ii-th point of interest.

The fourth line contains one integer qq (1q51051 \le q \le 5 \cdot 10^5) — the number of queries.

The fifth line contains qq integers f1,f2,,fqf_1, f_2, \dots, f_q (1fid11 \le f_i \le d - 1), where fif_i is the integer representing the ii-th query.

Additional constraint on the input: during the processing of each query, no coordinate contains more than one object (i. e. there cannot be two or more lanterns with the same coordinate, two or more points of interest with the same coordinate, or a lantern and a point of interest with the same coordinate).

For each query, print one integer — the answer to it, taken modulo 998244353998244353.

Input

The first line contains three integers dd, nn and mm (4d31054 \le d \le 3 \cdot 10^5; 1n21051 \le n \le 2 \cdot 10^5; 1m161 \le m \le 16) — the size of the segment, the number of lanterns and the number of points of interest, respectively.

The second line contains nn integers l1,l2,,lnl_1, l_2, \dots, l_n (1lid11 \le l_i \le d - 1), where lil_i is the coordinate of the ii-th lantern.

The third line contains mm integers p1,p2,,pmp_1, p_2, \dots, p_m (1pid11 \le p_i \le d - 1), where pip_i is the coordinate of the ii-th point of interest.

The fourth line contains one integer qq (1q51051 \le q \le 5 \cdot 10^5) — the number of queries.

The fifth line contains qq integers f1,f2,,fqf_1, f_2, \dots, f_q (1fid11 \le f_i \le d - 1), where fif_i is the integer representing the ii-th query.

Additional constraint on the input: during the processing of each query, no coordinate contains more than one object (i. e. there cannot be two or more lanterns with the same coordinate, two or more points of interest with the same coordinate, or a lantern and a point of interest with the same coordinate).

Output

For each query, print one integer — the answer to it, taken modulo 998244353998244353.

Sample Input 1

6 1 1
4
3
3
2 1 5

Sample Output 1

48
47
47

Sample Input 2

6 1 2
4
2 5
2
1 3

Sample Output 2

44
46

Sample Input 3

20 1 2
11
15 7
1
8

Sample Output 3

413

Sample Input 4

20 3 5
5 7 18
1 6 3 10 19
5
4 17 15 8 9

Sample Output 4

190431
187503
188085
189903
189708