var cup = [0,0,0] let N:Int = Int(readLine()!)! cup[N - 1] = 1 let M:Int = Int(readLine()!)! for _ in 1...M{ let PQ = readLine()!.split(separator:" ").map{Int($0)!} let P = PQ[0] - 1 let Q = PQ[1] - 1 cup.swapAt(P, Q) } let index = cup.firstIndex(of: 1)! print(index + 1)