ATP is a cute caterpillar living in the SK (Shik Kingdom). To prove that she's the bravest caterpillar in the world, she's going to participate a dangerous game. The rule is pretty easy: First, the participant should choose a grid of the NxM board. The game has K+1 stages and some of the rows and columns will become red each stage (It may turn back black at the next stage). The participant can either stay at current grid or move to one of the adjacent grids (eight-direction) between each stage. If the participant stands on a row or a column that was red at the previous stage, she'll be squashed. (Note that no rows or columns will become red at the (K + 1)-th stage.)
What a mad game! It's impossible to survive! Well, it's not the case for ATP, a brilliant hacker. ATP has hacked into the system and pulled out all the data about the game, hence she's able to predict what rows and columns will become red at each stage. Now, the problem is to find out a safe path.
There is an integer T in the first line, representing the number of test cases. The first line of each test case contains three numbers N, M, K. The (3xi-2)-th to (3xi)-th lines in the next 3xK lines describe the rows and columns that become red at the i-th stage. The first line of the three lines contains two integers X, Y. The stage contains X integers, representing the rows that become red. The third line contains Y integers, representing the columns that become red. Index begins from one.
1<=T<=10
1<=N, M, K<=1000
1<=X<=N
1<=Y<=M
You should output one line for each test case. Note that ATP will be angry if you tell her the path, hence you should only output a number representing the number of initial position that can survive.