package yukicoder; import java.util.Scanner; public class No_26v2 { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int[] cup = new int[3]; int N = sc.nextInt(); int M = sc.nextInt(); cup[N - 1] = 1; for(int i = 0; i < M; i++){ int sf1 = sc.nextInt() - 1; int sf2 = sc.nextInt() - 1; int tmp; tmp = cup[sf1]; cup[sf1] = cup[sf2]; cup[sf2] = tmp; } sc.close(); for(int i = 0; i < 3; i++){ if(cup[i] == 1){ System.out.println(i + 1); break; } } } }