let n = stdin.ReadLine () |> int let arr = [| for _ in 0..n-1 -> let [|t; s|] = stdin.ReadLine().Split " " int t, s |] // let write: (int*string)*(int*string) -> int*string = function // | (_, prev), (0, s) -> (0, prev + s) // | (_, prev), (1, s) -> (1, s + prev) // // let writeWrap a b = // write (a, b) let mutable ans = "" for t, s in arr do match t with | 0 -> ans <- ans + s | _ -> ans <- s + ans printfn "%s" ans // Array.reduce writeWrap arr |> snd |> printfn "%s"