q=['',''] gets.to_i.times do f,c=gets.chomp.split q[f.ord-48] << c end puts q[1].reverse+q[0]