Limits 2s, 512 MB

Jackal and Bari have started solving problems in Online Judges. And in order to do well, they know that they should learn new algorithms and data structures.
Now it is time to form teams for the ICPC regional contest. And so, their coach wants to know how many algorithms they have learned so far.
As both are programmers, they have given the algorithms list in a text file. And as they know so many algorithms, some of the algorithms in their text files can be repeated mistakenly.

Input

The first line of input contains T, The total number of test cases.
The next line contains two integers, n and m.
Next n lines contain the name of algorithms that Jackal knows. Then m lines follow, which contain the algorithms that Bari knows. The algorithm’s name is without any white-space.

Constraints:

T<=10
n<=1000
m<=1000
|A| <=20 ( here |A| is the length of the name of any algorithms )

Output

For each test case, print the case number. Then output the algorithms that Jackal and Bari know. The first line of output should be the total number of algorithms that Jackal knows and next line is the total number of algorithms that Bari knows. You should count any algorithm only once for a person which are listed more than once. See sample input and output for details.

Sample

InputOutput
1
5 4
BFS
DFS
Prim’s
DFS
Dijkstra
BFS
Kruskal’s
BellmenFord
DFS
Case 1:
Jackal 4
Bari 4

[N.B: DFS appears twice for Jackal, but it is considered only once for him. So, output for Jackal is 4]

Submit

Login to submit.

Statistics

83% Solution Ratio
aminulEarliest, Feb '17
koushikFastest, 0.0s
himuhasibLightest, 131 kB
C223428_hossainShortest, 424B
Toph uses cookies. By continuing you agree to our Cookie Policy.