def ascan; gets.split.map(&:to_i); end strs = gets.to_i.times.map{(gets.chomp+'~').chars} ans = '' while !strs.empty? item, i = strs.each_with_index.min ans << strs[i].shift strs.delete_at(i) if strs[i].empty? end puts ans.gsub('~','')