Under construction

Still being built. Things may change

Broken Device

Time limit2sMemory limit512 MB

Summary
Build a 150-bit sequence for a 64-bit integer X so the receiver can recover X even when up to 40 unknown positions are forced to 0.
Level

Hard8 of 10

Topics
Bit manipulation, Math, Combinatorics
Solved
No attempts yet

Problem

Anna and Bruno are archaeologists. They are investigating ruins in Iran.

Their tasks are as follows: Anna visits the ruins and discovers artifacts, and Bruno analyzes the results at the base camp.

Their investigation is scheduled for QQ (= 1000) days. Every day, Anna sends the day's result to Bruno with a communication device. The result for each day is an integer XX.

Anna can use the communication device once per day only. It can send a sequence of length NN (= 150) consisting of 0s and 1s.

However, the device is broken. The sequence of length NN has several broken positions. At a broken position, the device always sends 0, regardless of the value Anna sets. Anna can see the broken positions when she sends a sequence, but Bruno does not know them. The broken positions and their number can change every day.

There is a danger that the investigation will be delayed. You are a candidate for the international programming contest in Iran, so Anna and Bruno ask you to write a program that sends the results of their investigation.

Write two programs that make the communication between Anna and Bruno work.

  • The first program takes the sequence length NN, the integer to send XX, the number of broken positions KK, and the broken positions PP, and sets the sequence SS that Anna sends.
  • The second program takes the sequence AA that Bruno receives and recovers the integer XX.

At a working position, SS and AA have the same value. At a broken position, AA always has the value 0 regardless of the value of SS.

Input

The sample grader reads the following data from standard input.

  • The first line contains an integer QQ.
  • Then, the information of QQ queries is given.
  • The information of each query consists of two lines.
    • The first line contains three space-separated integers NN, XX, KK. This means the length of the sequence to send is NN, the integer Anna sends is XX, and there are KK broken positions.
    • The second line contains KK space-separated integers P0,P1,⋯ ,PK−1P_0, P_1, \cdots, P_{K-1}. This means that for each ii (0≤i≤K−10 \le i \le K - 1), the PiP_i-th position in the sequence is broken.

Output

When the program terminates successfully, the sample grader writes the following information to standard output. (Quotation marks are not actually written.)

  • If your program is judged as Wrong Answer, the grader writes the type in the form Wrong Answer [1], and your program is terminated.
  • If no call to Anna is judged as Wrong Answer, the grader writes Accepted and the value of L∗L^*. For the value of L∗L^*, see Scoring.

If your program falls under several types of Wrong Answer, the grader reports only one of them.

Constraints

  • Q=1000Q = 1000.
  • N=150N = 150.
  • 0≤X≤10180 \le X \le 10^{18}.
  • 1≤K≤401 \le K \le 40.
  • 0≤Pi≤N−10 \le P_i \le N - 1 (0≤i≤K−10 \le i \le K - 1).
  • Pi<Pi+1P_i < P_{i+1} (0≤i≤K−20 \le i \le K - 2).

Examples1

  1. Example 1

    Input
    1
    150 0 1
    0
    
    Expected output
    000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000