Top 25 Poll Comparison
InterviewTime limit10sMemory limit256 MB
Split two rankings of the same teams into the smallest consecutive groups that hold the same teams and print each size.
Problem
In college football, many different sources publish their own list of the top 25 teams in the country. Ranking is subjective, so these lists differ, but they are usually close. Compare two such lists and find how far they agree.
Split the positions of the two lists into consecutive groups. Each group covers the same range of positions in both lists and holds the same set of teams in both lists. Make the groups as small as possible under that rule. If the two lists are identical, there are groups.
Take these two lists.
There are 3 groups.
A
B C D
E
Input
The first line contains the number of test cases , where .
The first line of each test case contains the number of ranked teams , where . The next lines hold the first list in ranked order, one team per line. The following lines hold the second list in the same format.
A team name consists of at most 8 capital letters. Both lists contain the same team names, and within one test case all names are distinct.
Output
For each test case, print the size of each group in order on one line, separated by single spaces. Print no extra spaces and no blank lines between the numbers.