35A.md (1521B)
1 Source: https://codeforces.com/problemset/problem/35/A 2 3 A. Shell Game 4 5 time limit per test 6 7 2 seconds 8 9 memory limit per test 10 11 64 megabytes 12 13 input 14 15 input.txt 16 17 output 18 19 output.txt 20 21 Today the «Z» city residents enjoy a shell game competition. The residents are gathered on the main square to watch the breath-taking performance. The performer puts 3 non-transparent cups upside down in a row. Then he openly puts a small ball under one of the cups and starts to shuffle the cups around very quickly so that on the whole he makes exactly 3 shuffles. After that the spectators have exactly one attempt to guess in which cup they think the ball is and if the answer is correct they get a prize. Maybe you can try to find the ball too? 22 23 Input 24 25 The first input line contains an integer from 1 to 3 — index of the cup which covers the ball before the shuffles. The following three lines describe the shuffles. Each description of a shuffle contains two distinct integers from 1 to 3 — indexes of the cups which the performer shuffled this time. The cups are numbered from left to right and are renumbered after each shuffle from left to right again. In other words, the cup on the left always has index 1, the one in the middle — index 2 and the one on the right — index 3. 26 27 Output 28 29 In the first line output an integer from 1 to 3 — index of the cup which will have the ball after all the shuffles. 30 31 Examples 32 33 Input 34 35 ``` 36 1 37 1 2 38 2 1 39 2 1 40 ``` 41 42 Output 43 44 ``` 45 2 46 ``` 47 48 Input 49 50 ``` 51 1 52 2 1 53 3 1 54 1 3 55 ``` 56 57 Output 58 59 ``` 60 2 61 ```