import java.util.*; public class Main { private static Scanner sc = new Scanner(System.in); public static void main(String[] args) throws Exception { boolean[] b = new boolean[4]; int n = sc.nextInt(); b[n] = true; int m = sc.nextInt(); for (int i = 0;i < m;i++) { int p = sc.nextInt(); int q = sc.nextInt(); boolean tmp = b[p]; b[p] = b[q]; b[q] = tmp; } for (int i = 1;i <= 3;i++) { if (b[i]) System.out.println(i); } } }