open System let n = stdin.ReadLine() |> int let rec loop l r cnt = if cnt = 0 then l @ List.rev r |> String.Concat else let [| t; s |] = stdin.ReadLine().Split() if t = "0" then loop l (s :: r) (cnt - 1) else loop (s :: l) r (cnt - 1) loop [] [] n |> printfn "%s"