N = gets.to_i S = N.times.map { gets.chomp + '{' } T = [] loop { best_i = -1 N.times do |i| next if S[i].size <= 1 if best_i == -1 || (S[i] < S[best_i]) best_i = i end end break if best_i == -1 T << S[best_i][0] S[best_i][0] = '' } puts T.join