TopCoder

User's AC Ratio

NaN% (0/0)

Submission's AC Ratio

NaN% (0/0)

Tags

Description



<!-- MATH
$\epsfbox{p4147.eps}$
-->
WIDTH="281" HEIGHT="485" ALIGN="right" BORDER="0"
SRC="/ntujudge/problemdata/637-1.jpg"
ALT="\epsfbox{p4147.eps}">


In Jollybee Chess Championship 2008, there are a number of players who have withdrawn themselves from the championship of 64 players (in this problem, we generalized it into 2N

players). Due to the nature of the competition, which is a regular knock-out tournament, and also the short notice of the withdrawals, some matches had been walkover matches (also known as a w/o, a victory due to the absent of the opponent).


If both players are available then there will be a normal match, one of them will advance to the next phase. If only one player is available then there will be a walkover match, and he/she will automatically advance. If no player is available then there will be no match.


In the left figure, the player #3 and #4 are withdrawn from the tournament, leaving a total of one w/o match (at match #3).


Given the list of players who withdraw right before the tournament start, calculate how many w/o matches to happen in the whole tournament, assuming that all of the remaining players play until the end of the tournament (winning or knocked-out).

Input Format


The first line of input contains an integer T

, the number of test cases to follow. Each case begins with two integers, N
<!-- MATH
$(1 \le N \le 10)$
-->
(1 WIDTH="18" HEIGHT="31" ALIGN="MIDDLE" BORDER="0"
SRC="/ntujudge/problemdata/637-2.png"
ALT="$ \le$">N WIDTH="18" HEIGHT="31" ALIGN="MIDDLE" BORDER="0"
SRC="/ntujudge/problemdata/637-2.png"
ALT="$ \le$">10)

and M
<!-- MATH
$(0 \le M \le 2N)$
-->
(0 WIDTH="18" HEIGHT="31" ALIGN="MIDDLE" BORDER="0"
SRC="/ntujudge/problemdata/637-2.png"
ALT="$ \le$">M WIDTH="18" HEIGHT="31" ALIGN="MIDDLE" BORDER="0"
SRC="/ntujudge/problemdata/637-2.png"
ALT="$ \le$">2N)

. The next line contains M
integers, denoting the players who have withdrawn themselves right before the tournament. The players are numbered from 1 to 2N
, ordered by their position in the tournament draw.

Output Format


For each case, print in a single line containing the number of walkover matches.

Sample Input 1



3
2 2
3 4
3 5
1 2 3 4 5
2 1
2



Sample Output 1



1
2
1

Hints

Problem Source

Migrated from old NTUJ.

ACM ICPC regional Jakarta site 2008

Subtasks

No. Testdata Range Score

Testdata and Limits

No. Time Limit (ms) Memory Limit (VSS, KiB) Output Limit (KiB) Subtasks
0 10000 65536 200