n = read_line.to_i s = (1..n).map { read_line } ans = "" while s.any? { |s| !s.empty? } pos = s.each_with_index.min_by { |(s, i)| {s.ljust(50, '~'), i} }[1] ans += s[pos][0] s[pos] = s[pos][1..] end puts ans