open System let swap (cs:'t array) i j = let tmp = cs.[i] cs.[i] <- cs.[j] cs.[j] <- tmp type Sol() = member this.Solve() = let cups = [|'x';'x';'x'|] let N = stdin.ReadLine() |> int cups.[N-1] <- 'o' let M = stdin.ReadLine() |> int for i = 0 to (M-1) do let [|P;Q|] = stdin.ReadLine().Split() |> Array.map int swap cups (P-1) (Q-1) 1 + (Array.findIndex (fun e -> e = 'o') cups ) |> printfn "%d" let mySol = new Sol() mySol.Solve()