This page is still under construction.

Parts of this page are still being built. What you see may change.

Rock paper scissors

Time limit1sMemory limit256 MB

Summary
Read the past rounds and print 0 when there are none, 2 when the opponent last threw rock, and 0 otherwise.
Level

Easy1 of 10

Topics
Implementation
Solved
No attempts yet

Problem

Rock paper scissors is a game in which two players each throw scissors, rock, or paper at the same time. Scissors beat paper, rock beats scissors, and paper beats rock. Matching throws are a tie.

Scissors is 00, rock is 11, and paper is 22.

You already played NN rounds against the opponent. Choose the next throw by this rule.

  • If N=0N = 0, throw 00.
  • If N≥1N \ge 1, let bb be the opponent's throw in the last round. Throw 22 when b=1b = 1, and throw 00 otherwise.

Earlier wins, losses, and your own past throws do not change the next throw.

Input

The first line contains NN. (0≤N≤100000 \le N \le 10000)

Each of the next NN lines contains two integers, your throw and the opponent's throw, separated by a space. Each value is 00, 11, or 22.

If N=0N = 0, there are no further lines.

Output

Print the next throw on one line. Scissors is 00, rock is 11, and paper is 22.

Hint

N=0N = 0 is the start of the match, so there is no prior result. Print 00 in that case. Otherwise only the opponent's last throw matters.

Examples4

  1. Example 1

    Input
    0
    
    Expected output
    0
    
  2. Example 2

    Input
    1
    0 1
    
    Expected output
    2
    
  3. Example 3

    Input
    2
    0 1
    2 1
    
    Expected output
    2
    
  4. Example 4

    Input
    3
    0 1
    2 1
    2 0
    
    Expected output
    0