import java.util.Scanner; public class No26 { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int[] cups = new int[3]; cups[n - 1] = 1; int m = sc.nextInt(); for (int i = 0; i < m; i++) { int p = sc.nextInt(); int q = sc.nextInt(); doChange(cups, p, q); } for (int i = 0; i < cups.length; i++) { if (cups[i] == 1) { System.out.println(i + 1); break; } } sc.close(); } private static void doChange(int[] cups, int p, int q) { int tmpP = cups[p - 1]; int tmpQ = cups[q - 1]; cups[p - 1] = tmpQ; cups[q - 1] = tmpP; } }