puts Array.new(gets.to_i){ gets.split }.reduce(""){|a, b| a = (b[0] == 0 ? a + b[1] : b[1] + a)}