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) Array.reduce writeWrap arr |> snd |> printfn "%s"