import java.util.Scanner; public class Yukicoder26 { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int N = sc.nextInt(); int M = sc.nextInt(); int P, Q; boolean[] cup = {false, false, false}; cup[N - 1] = true; for (int i = 0; i < M; i++) { P = sc.nextInt(); Q = sc.nextInt(); cup[P - 1] ^= cup[Q - 1]; cup[Q - 1] ^= cup[P - 1]; cup[P - 1] ^= cup[Q - 1]; } for (int i = 0; i < 3; i++) if (cup[i]) System.out.println(i + 1); } }