We’re preparing your current view and syncing the latest data.
There are three shells numbered 1 to 3. Initially, the ball is under one of the shells. Then, a series of swaps between two shells are performed. Your task is to determine under which shell the ball is after all swaps.
The first line contains an integer B (1 ≤ B ≤ 3) — the initial position of the ball. The second line contains an integer N (1 ≤ N ≤ 100) — the number of swaps. Then follow N lines, each containing two distinct integers a and b (1 ≤ a, b ≤ 3) — the shells that swap positions.
Output the number of the shell where the ball is after performing all swaps.
1 ≤ B ≤ 3 1 ≤ N ≤ 100 1 ≤ a, b ≤ 3; a ≠ b