using System; using System.Linq; class Program { static void Main() { bool[] cup = new bool[3]; cup[int.Parse(Console.ReadLine()) - 1] = true; int n = int.Parse(Console.ReadLine()); for(int i = 0; i < n; i++) { int[] change = Console.ReadLine().Split().Select(a => int.Parse(a) - 1).ToArray(); bool temp = cup[change[0]]; cup[change[0]] = cup[change[1]]; cup[change[1]] = temp; } Console.WriteLine($"{cup.Select((a, i) => new {Content = a, Index = i}).Where(a => a.Content).Select(a => a.Index + 1).ToArray()[0]}"); } }