using System; public class Hello { public static void Main() { var a = new int[3]; a[0] = 0; a[1] = 1; a[2] = 2; var t = int.Parse(Console.ReadLine().Trim()) - 1; var n = int.Parse(Console.ReadLine().Trim()); for (int i = 0; i < n; i++) { string[] line = Console.ReadLine().Trim().Split(' '); var p = int.Parse(line[0]) - 1; var q = int.Parse(line[1]) - 1; swap(a, p, q); } for (int i = 0; i < 3; i++) if (a[i] == t) { Console.WriteLine(i + 1); break; } } public static void swap(int[] a, int p, int q) { var w = a[p]; a[p] = a[q]; a[q] = w; } }