package yukicoder; import java.util.Scanner; public class No_026 { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int N = sc.nextInt(); int M = sc.nextInt(); int[] cup = new int[4]; cup[N] = 1; for(int i = 0; i < M; i++){ int[] shuf = new int[2]; shuf[0] = sc.nextInt(); shuf[1] = sc.nextInt(); if(cup[shuf[0]] == 1){ cup[shuf[0]] = 0; cup[shuf[1]] =1; }else if(cup[shuf[1]] == 1){ cup[shuf[1]] = 0; cup[shuf[0]] = 1; } } for(int i = 1; i < 4; i ++){ if(cup[i] == 1){ System.out.println(i); break; } } } }