1043 - I2P EECS 2016 HW5 Scoreboard

Time

2016/10/13 17:00:00 2016/10/19 09:00:00

Clarification

# Problem Asker Description Reply Replier Reply Time For all team

# Problem Pass Rate (passed user / total user)
10766 Shell Game

10766 - Shell Game   

Description

In a shell game, balls with different numbers are hidden beneath identical containers, which are placed in a line. After the containers are shuffled, players need to guess the order of balls.

 

In this problem, there are five balls, numbered 0-4, and placed under five identical containers. The containers are placed in a straight line, and the initial positions of balls are from 0-4. The problem will then give k swaps of containers. Each swap is represented by a pair of integers, (a,b), meaning the container is position a is swapped with the container in position b. Your program needs to print the final ordering of balls.

 

For example, k=3, and three swaps are

0 4

2 3

1 2

 

Initially, the order of balls is: 0 1 2 3 4. After the swap (0,4), the order of balls becomes: 4 1 2 3 0; After the swap (2,3), the order of balls becomes: 4 1 3 2 0; and after the swap (1,2), the order of balls becomes:

4 3 1 2 0. So your program needs to print

4 3 1 2 0

Input

The first line of the input is an integer k (0 < k < 25), which specifies the number of swaps. In the next k lines, each line contains a pair of integers, specifying the two positions to be swapped.

Output

The order of balls after swaps. Note that you do not need to print ‘\n’ at the end of the output.

Sample Input  Download

Sample Output  Download

Tags

10401Contest



Discuss