import java.util.Scanner; public class Main{ public static void main(String[] args) { Scanner scan = new Scanner(System.in); int N = scan.nextInt(); int M = scan.nextInt(); int []P = new int[M]; int []Q = new int[M]; for(int i = 0; i < M; i++) { P[i] = scan.nextInt(); Q[i] = scan.nextInt(); } scan.close(); int ans = N; for(int i = 0; i < M; i++) { if(ans == P[i]) { ans = Q[i]; }else if(ans == Q[i]){ ans = P[i]; } } System.out.println(ans); } }