CF2005B1.The Strict Teacher (Easy Version)

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

The Strict Teacher (Easy Version)

This is the easy version of the problem. The only differences between the two versions are the constraints on mm and qq. In this version, m=2m=2 and q=1q=1. You can make hacks only if both versions of the problem are solved.

Narek and Tsovak were busy preparing this round, so they have not managed to do their homework and decided to steal David's homework. Their strict teacher noticed that David has no homework and now wants to punish him. She hires other teachers to help her catch David. And now mm teachers together are chasing him. Luckily, the classroom is big, so David has many places to hide.

The classroom can be represented as a one-dimensional line with cells from 11 to nn, inclusive.

At the start, all mm teachers and David are in distinct cells. Then they make moves. During each move

  • David goes to an adjacent cell or stays at the current one.
  • Then, each of the mm teachers simultaneously goes to an adjacent cell or stays at the current one.

This continues until David is caught. David is caught if any of the teachers (possibly more than one) is located in the same cell as David. Everyone sees others' moves, so they all act optimally.

Your task is to find how many moves it will take for the teachers to catch David if they all act optimally.

Acting optimally means the student makes his moves in a way that maximizes the number of moves the teachers need to catch him; and the teachers coordinate with each other to make their moves in a way that minimizes the number of moves they need to catch the student.

Also, as Narek and Tsovak think this task is easy, they decided to give you qq queries on David's position. Note: this is the easy version, and you are given only one query.

Input

In the first line of the input, you are given a single integer tt (1t1051 \le t \le 10^5) — the number of test cases. The description of each test case follows.

In the first line of each test case, you are given three integers nn, mm, and qq (3n1093 \le n \le 10^9, m=2m=2, q=1q=1) — the number of cells on the line, the number of teachers, and the number of queries.

In the second line of each test case, you are given mm distinct integers b1,b2,,bmb_1, b_2, \ldots, b_m (1bin1 \le b_i \le n) — the cell numbers of the teachers.

In the third line of each test case, you are given qq integers a1,a2,,aqa_1, a_2, \ldots, a_q (1ain1 \le a_i \le n) — David's cell number for every query.

It is guaranteed that for any ii, jj such that 1im1 \le i \le m and 1jq1 \le j \le q, biajb_i \neq a_j.

Output

For each test case, output qq lines, the ii-th of them containing the answer of the ii-th query.

Note

In the first example, the student can just stay at cell 22. The teacher, initially located in cell 11, can reach cell 22 in one move. Therefore, the answer is 11.

In the second example, the student should just stay at cell 11. The teacher, initially located in cell 33, can reach cell 11 in two moves. Therefore, the answer is 22.

Samples

3
10 2 1
1 4
2
8 2 1
3 6
1
8 2 1
3 6
8
1
2
2

在线编程 IDE

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