cup = [False] * 3 N = int(input()) cup[N - 1] = True M = int(input()) for i in range(M): a, b = list(map(int, input().split())) tmp = cup[a - 1] cup[a - 1] = cup[b - 1] cup[b - 1] = tmp for i in range(3): if cup[i]: print(i + 1)