defmodule Main do def main do 1..(IO.read(:line) |> String.trim() |> String.to_integer()) |> Enum.map(fn _ -> IO.read(:line) |> String.trim() |> String.split() end) |> solve_rec([]) |> IO.puts() end def solve_rec([], r) do r |> Enum.join() end def solve_rec([{t, s} | l], r) do case t do "0" -> solve_rec(l, r |> List.insert_at(-1, s)) "1" -> solve_rec(l, [s | r]) end end end