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 end def solve_rec([[t, s] | l], r) do case t do "0" -> solve_rec(l, "#{r}#{s}") "1" -> solve_rec(l, "#{s}#{r}") end end end