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