Two regional programming contests were held in St. Petersburg. A participant who competed in both of them wants to build a single overall rating for every team that took part in at least one contest.
Each team has a unique identifier: an integer from 1 to 100. For each contest the identifiers of the participating teams are written in a column, ordered from best to worst, and teams that finished with the same result are written together on one line.
Definition: a team has place K in a contest if exactly K−1 teams finished strictly better than it.
For example, consider the results of two contests:
| Contest 1 | Contest 2 | ||
|---|---|---|---|
| place | team id | place | team 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 |
The overall rating is defined by the following rules.
For two teams that both competed in both contests:
(Equivalently, for teams that competed in both contests a smaller sum of the two places means a higher overall rating, and equal sums mean equal rating.)
In the example only teams 1, 4, 5, and 9 competed twice. Team 1 has the highest rating, then teams 5 and 9 tie, and team 4 is lowest.
A team that competed in only one contest cannot always be given an overall rating. Such a team is inserted into the overall list (in which the teams that competed twice are already placed by the rules above) only when one of the following holds:
A. If a team that competed in both contests shared this team's place in that one contest, then this team takes the same overall rating as that team. If several such teams exist, they must all have the same overall rating; otherwise this team's rating is undetermined.
B. Otherwise, if there is a position in the overall list (at the very beginning, at the very end, or between two lines) such that every team before it finished better than this team in their common contest and every team after it finished worse, then this team takes that position. If several teams claim the same position, they are ordered among themselves by their places (a smaller place comes first, and teams with equal place share a line).
Illustration of the example:
| Teams in both contests | Teams in one contest only |
|---|---|
| 3 | |
| 1 | 10 |
| 9 5 | |
| 19 | |
| 4 | 20 |
| 15 8 | |
| 31 18 | |
| 17 21 |
Write a program that builds the overall rating list from the two contest result tables and the rules above.
The input describes two contests, separated by an empty line. Each description begins with a line containing a single integer N (1≤N≤100), the number of result lines that follow. Each of those lines contains one or more team identifiers separated by spaces. Within one contest every identifier appears at most once.
Print the overall rating list: one or more lines of team identifiers separated by spaces, from the highest overall rating to the lowest, with teams that share the same rating on one line. Within each line print the identifiers in increasing order. Teams whose overall rating is undetermined must not appear.