#P7099. [yLOI2020] 灼

[yLOI2020] 灼

Description

This is NS05. There is no sign of life left on the Leiben planet. Requesting rescue! Puer! Can you hear me? I will stay here and wait for your return.

Fusu is trapped on the Leiben planet. Zhuo Wenyu is piloting a spaceship and plans to travel through a wormhole to reach Leiben and rescue Fusu.

On a number line, there are nn wormholes. The coordinate of the ii-th wormhole is xix_i. Entering any one of these wormholes can directly take you to Leiben and rescue Fusu. After the spaceship reaches the straight line containing the number line, it will lose control due to the magnetic field. Each second, it will move one unit to the left or to the right with equal probability.

Zhuo Wenyu is very anxious. He gives qq initial coordinates where the spaceship enters the line of the number line. For each coordinate, he wants to know the expected number of seconds needed to reach a wormhole.

If the expected value you compute is a fraction, you need to output the value modulo 998244353998244353. For the definition of taking a fraction modulo a prime, you can refer to the content in “Hint”.

To avoid the output being too large, you only need to output four integers: the bitwise XOR of all answers (after taking modulo 998244353998244353, same below), how many of your answers are odd, the maximum among all your answers, and the minimum among all your answers.

Input Format

The first line contains an integer TT, which is the index number corresponding to the test point.
The second line contains two integers, representing the number of wormholes nn and the number of initial coordinates qq.
The third line contains nn integers. The ii-th integer represents the coordinate of the ii-th wormhole xix_i.
The next qq lines each contain one integer, representing an initial coordinate yjy_j where the spaceship enters the line of the number line.

It is guaranteed that yjy_j are given in non-decreasing order.

Output Format

Output four lines, each containing one integer, in order: the bitwise XOR of all answers, how many answers are odd, the maximum answer, and the minimum answer.

0
2 3
1 3
1
2
3

1
1
1
0

Hint

Sample 1 Explanation

There are wormholes at points 11 and 33 on the number line. When the initial coordinate is 11 or 33, the spaceship can enter a wormhole immediately and costs 0s0s. When the initial coordinate is 22, there is a probability of 12\frac 1 2 to move one unit to the left, costing 1s1s to enter a wormhole, and also a probability of 12\frac 1 2 to move one unit to the right, costing 1s1s to enter a wormhole. The expected time is 12×(1+1)=1\frac 1 2 \times (1 + 1) = 1.

Therefore, the answers to the three queries are 0,1,00, 1, 0.

Constraints and Conventions

This problem has 1010 test points, and each test point is worth 1010 points.

  • For 10%10\% of the testdata, it is guaranteed that n=1n = 1.
  • For 20%20\% of the testdata, it is guaranteed that for any wormhole, there always exists another wormhole such that the distance between them is at most 22. For example, in the sample, the distance between the two wormholes is 22.
  • For 30%30\% of the testdata, it is guaranteed that for any wormhole, there always exists another wormhole such that the distance between them is at most 33.
  • For 50%50\% of the testdata, it is guaranteed that xi,q100x_i, q \leq 100.
  • For 70%70\% of the testdata, it is guaranteed that xi,q105x_i, q \leq 10^5.
  • For 100%100\% of the testdata, it is guaranteed that 1n1051 \leq n \leq 10^5, 1q5×1061 \leq q \leq 5 \times 10^6, 1xi,yj1091 \leq x_i, y_j \leq 10^9. Also, yjy_j is not less than the minimum of xix_i, and yjy_j is not greater than the maximum of xix_i. The values yjy_j are given in non-decreasing order.

Hint

  • If you do not know what it means to take a fraction modulo a prime, you can refer to the following:

    For an irreducible fraction of the form ab\frac a b, where b<998244353b \lt 998244353, its value modulo 998244353998244353 is a×b998244351mod998244353a \times b^{998244351} \bmod {998244353}.

  • To make it easier to generate data by hand, the data does not guarantee that all xix_i are distinct.

  • Please note that reading a large amount of data may affect the efficiency of your program.

  • This special output format is only to avoid TLE due to overly large output, and it is unrelated to the solution of this problem.

  • Please note that TT is not the number of test cases.

  • This problem has two additional files; see zhuo.zip in the attachment files.

Translated by ChatGPT 5