import java.util.Arrays; import java.util.LinkedList; import java.util.Scanner; public class Main { public static void main(String[] args){ Scanner sc = new Scanner(System.in); final int N = sc.nextInt() - 1; final int M = sc.nextInt(); boolean[] in = new boolean[3]; in[N] = true; for(int i = 0; i < M; i++){ final int P = sc.nextInt() - 1; final int Q = sc.nextInt() - 1; final boolean tmp = in[P]; in[P] = in[Q]; in[Q] = tmp; } for(int i = 0; i < 3; i++){ if(in[i]){ System.out.println((i + 1)); break; } } } }