using System; using System.Collections.Generic; using System.Linq; public class Program { static void Swap(ref T lhs, ref T rhs) { T temp; temp = lhs; lhs = rhs; rhs = temp; } public static void Main(string[] args) { var initPos = int.Parse(Console.ReadLine()) - 1; var swapTimes = int.Parse(Console.ReadLine()); var nums = new int[]{ 1, 2, 3 }; var correct = nums[initPos]; int[] poses; for (var i = 0; i < swapTimes; i++) { poses = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray(); Swap(ref nums[poses[0]-1], ref nums[poses[1]-1]); } Console.WriteLine(Array.IndexOf(nums, correct)+1); } }