while n = gets.to_i
    break if n == 0
    puts gets.chomp
    ss = []
    colon = [0] * (n-1)
    (n - 1).times do |i|
        s = gets.chomp
        s.gsub!(/\.(\w)/, '+\1')
        colon[i] = s.count('.')
        s.gsub!(/\./, ' ')
        ss << s
    end
    max = colon.max
    pos = [-1] * (max + 1)
    (n - 2).times do |idx|
        if colon[idx] > colon[idx + 1]
            (pos[colon[idx + 1]]+1..idx).each do |i|
                ss[i][colon[idx + 1]] = '|'
            end
        end
        pos[colon[idx]] = idx
    end
    ss.each {|s| puts s}
end