Into two teams
Soccer is a favorite game among children, but to play a match, they need to form two teams. To make the game exciting, the teams should be as evenly matched as possible.
In one neighborhood, the kids decided to form teams in the following manner: The two strongest players become team captains and are assigned the numbers 1 and 2. Captain 1 picks the first player for their team. Then, from the remaining players, captain 2 selects the first player for their team. For the next round of selections, captain 2 picks first. If there are still players left, the first choice goes back to captain 1, and so on. Essentially, after captain 1 selects the first player, the captains alternate picking two players each until all players are chosen. There are no restrictions on team sizes, so everyone gets to play. If there is an odd number of players, one team will have one extra player.
Given the captains' ratings of the players, determine which player will join which team. Each captain's ratings are unique numbers from 1 to N-2, where N is the total number of players, including the captains. The rating indicates the player's position according to the captain in the overall list of players, excluding the captains. We will renumber all players, except the captains, from 1 to N-2, and the ratings will be listed in the order of player numbers—first the rating of the first player, then the second, and so on.
For instance, if the first captain's ratings are 1, 5, 6, 3, 2, 4, and the second captain's ratings are 1, 6, 4, 5, 3, 2, then initially, the first team will get player number 1. The second captain will then take player number 6 for their team, followed by player number 5. Next, the first captain will select two players (numbers 4 and 2), and the remaining player (number 3) will join the second team. This distribution can be represented as: 112122. Players numbered 1, 2, and 4 are in the first team, while players numbered 3, 5, and 6 are in the second team.
Input
The first line contains an integer N - the total number of players, excluding the captains (2 ≤ N ≤ 100). The second line contains N positive integers separated by spaces - the ratings of the first captain, and the third line contains the ratings of the second captain (also N positive integers).
Output
Output a single line with the answer to the problem.