CF2051C.Preparing for the Exam

传统题 时间 2000 ms 内存 256 MiB 5 尝试 1 已通过 1 标签

Preparing for the Exam

Monocarp is preparing for his first exam at the university. There are nn different questions which can be asked during the exam, numbered from 11 to nn. There are mm different lists of questions; each list consists of exactly n1n-1 different questions. Each list ii is characterized by one integer aia_i, which is the index of the only question which is not present in the ii-th list. For example, if n=4n = 4 and ai=3a_i = 3, the ii-th list contains questions [1,2,4][1, 2, 4].

During the exam, Monocarp will receive one of these mm lists of questions. Then, the professor will make Monocarp answer all questions from the list. So, Monocarp will pass only if he knows all questions from the list.

Monocarp knows the answers for kk questions q1,q2,,qkq_1, q_2, \dots, q_k. For each list, determine if Monocarp will pass the exam if he receives that list.

Input

The first line contains one integer tt (1t1041 \le t \le 10^4) — the number of test cases.

Each test case consists of three lines:

  • the first line contains three integers nn, mm and kk (2n31052 \le n \le 3 \cdot 10^5; 1m,kn1 \le m, k \le n);
  • the second line contains mm distinct integers a1,a2,,ama_1, a_2, \dots, a_m (1ain1 \le a_i \le n; ai<ai+1a_i \lt a_{i+1});
  • the third line contains kk distinct integers q1,q2,,qkq_1, q_2, \dots, q_k (1qin1 \le q_i \le n; qi<qi+1q_i \lt q_{i+1}).

Additional constraints on the input:

  • the sum of nn over all test cases does not exceed 31053 \cdot 10^5.

Output

For each test case, print a string of mm characters. The ii-th character should be 1 if Monocarp passes the exam if he receives the ii-th question list, 0 if Monocarp won't pass.

Note

In the first test case, Monocarp knows the questions [1,3,4][1, 3, 4]. Let's consider all the question lists:

  • the first list consists of questions [2,3,4][2, 3, 4]. Monocarp doesn't know the 22-nd question, so he won't pass;
  • the second list consists of questions [1,3,4][1, 3, 4]. Monocarp knows all these questions, so he will pass;
  • the third list consists of questions [1,2,4][1, 2, 4]. Monocarp doesn't know the 22-nd question, so he won't pass;
  • the fourth list consists of questions [1,2,3][1, 2, 3]. Monocarp doesn't know the 22-nd question, so he won't pass.

Samples

4
4 4 3
1 2 3 4
1 3 4
5 4 3
1 2 3 4
1 3 4
4 4 4
1 2 3 4
1 2 3 4
2 2 1
1 2
2
0100
0000
1111
10

在线编程 IDE

建议全屏模式获得最佳体验