Crossed Matchings

No attempts yetTime limit1sMemory limit128 MB

Problem

Positive integers are listed in two rows. If two equal numbers lie in different rows — one in the first row and the other in the second row — we may connect them with a single line segment. If the value of such a segment is rr, we call it an rr-matching segment. The figure below shows a 3-matching segment and a 2-matching segment.

For the given input, we want to draw as many matching segments as possible so that all of the following hold:

  1. Every aa-matching segment must cross exactly one bb-matching segment, where aba \neq b.
  2. No number may be an endpoint of more than one segment (each number is used by at most one segment). For example, the matchings shown below are not allowed.

Write a program that computes the maximum number of matching segments. Note that this number is always even.

Input

The first line contains the number of test cases MM (1M101 \le M \le 10). Each test case consists of three lines. The first line contains N1N_1 and N2N_2, the number of integers in the first and the second row, respectively. The next line contains the N1N_1 integers of the first row, and the following line contains the N2N_2 integers of the second row. All numbers are positive integers less than 100100.

Output

For each test case, print the maximum number of matching segments on its own line.