gets puts $<.readlines.map(&:chomp).map(&:split).reduce("") {|ac, e| e[0] == ?0 ? ac + e[1] : e[1] + ac}