# frozen_string_literal: true def solve(t_and_s, result) if t_and_s.empty? result else solve(t_and_s[1..-1], (case t_and_s.first[0] when '0' "#{result}#{t_and_s.first[1]}" when '1' "#{t_and_s.first[1]}#{result}" end)) end end N = gets.to_i T = N.times.map { gets.chomp.split } RESULT = solve(T, '') puts RESULT