import strutils, sequtils proc input: auto = stdin.readLine let N, M = input().parseInt var arr = "/xxx/" arr[N] = 'o' for i in 0 ..< M: var P, Q: int (P, Q) = input().split.map parseInt swap(arr[P], arr[Q]) echo find(arr, 'o')