One of the participants of both regional contests which took place in St. Petersburg decided to determine overall rating for all teams that took part in at least one contest.
This participant assigned each team a unique team identifier, which was an integer from 1 to 100 inclusively. For each contest team identifiers of the participating teams were written in a column according to their place in that contest. Identifiers of the teams that had equal results were written on the same line. The participant started with the team(s) that was(were) the best in that contest (writing them on the first line) and continued in the order of decreasing results.
Definition: Let's say that the team has place K in the contest if exactly K-1 teams performed in that contest better.
Consider the following examples of two contests' results:
Contest no. 1 | Contest no. 2 | ||
place | team's id | place | team's id |
1 | 9 | 1 | 3 |
2 | 7 1 4 | 2 | 5 |
5 | 5 | 3 | 1 10 |
6 | 15 8 | 5 | 6 |
8 | 31 18 | 6 | 9 |
10 | 17 | 7 | 19 |
| | 8 | 4 20 |
| | 10 | 21 |
Teams that participated in both contests | Teams that participated in one contest only |
| 3 |
1 | 10 |
9 5 | |
| 19 |
4 | 20 |
| 15 8 |
| 31 18 |
| 17 21 |
The input file contains a description of the two contests, which are separated by an empty line. Each description starts with a line containing the single integer N (1 <= N <= 100) that indicates how many lines of the contest result table follow. Each line of the contest result table consists of one or more team identifiers separated by spaces.
Every team identifier occurs at most once in the description of each contest.
Write to the output file one or more lines with the team identifiers (separated by spaces) that represent the overall rating list. The teams that share the same rating (thus written on the same line) is written in ascending order. The teams for which the overall rating is not determined should be absent in the output file.
6 9 7 1 4 5 15 8 31 18 17 8 3 5 1 10 6 9 19 4 20 21
3 1 10 5 9 19 4 20 8 15 18 31 17 21