Intersection of Two Sets

Time Limit: Java: 1000 ms / Others: 1000 ms

Memory Limit: Java: 32768 KB / Others: 32768 KB

Description

In this problem, you are asked to get the element count of the intersection of two integer sets.

Input

Standard input will contain multiple test cases. The first line of the input is a single integrate T (1 <= T <= 50) which is the number of test cases. T consecutive test cases followed. In each test case, there're several lines that contain the information of the two integer sets. The first line contains the element count S1 (1 <= S1 <= 100000) for set 1, followed by S1 lines, each line contains an integer in set 1. Then there's a line contains the element count S2 (1 <= S2 <= 100000) in set 2, and followed by S2 lines, each line contains an integer in set 2.

NOTE: there will be no duplicate elements in each sets and all the integers in each set will be sorted ascending.

Output

For each test case in the input, there's only one line output that contains the element count of the intesection of the two sets.

Sample Input

1
5
1
2
3
4
5
6
2
3
4
5
6
7

Sample Output

4

Hint

None

Source

ZOJ Monthly, May 2009

提交代码