package m.shin; import java.util.Scanner; public class Con26 { public static void main(String[] args) { Scanner s = new Scanner(System.in); int[] cup = new int[3]; int N = s.nextInt() , M = s.nextInt(); cup[N-1] = 1; for(int i = 0;i < M;i++){ int p = s.nextInt() , q = s.nextInt() , d = cup[q-1]; cup[q-1] = cup[p-1]; cup[p-1] = d; } s.close(); for(int i = 0;i < 3;i++){ if(cup[i] == 1){ System.out.println(i+1); } } } }