#include <utility> // pair make_pair
using std::swap; // c++11
using std::pair;
using std::make_pair;
#include <tuple> // tuple(c++11) make_tuple(c++11)
using std::tuple; // get<address>(variable)
using std::make_tuple;
#include <string> // string stoi(c++11) stoll(c++11) to_string(c++11)
using std::string;
using std::stoi;
using std::stoll;
using std::to_string;
#include <queue> // queue priority_queue
using std::queue;
using std::priority_queue;
#include <stack> // stack
using std::stack;
#include <vector> // vector
using std::vector;
#include <map> // map
using std::map;
#include <set> // set
using std::set; // insert erase find count
#include <algorithm> // min max
using std::sort;
using std::lower_bound; // iterator,  >=
using std::upper_bound; // iterator,  >
using std::min;
using std::max;
using std::min_element; // iterator
using std::max_element; // iterator
#include <iostream> // cin cout
using std::cin;
using std::cout;
using std::endl;
#include <complex> // complex
using std::complex; // real imag

#define lli long long int
#define INF (int)1e09
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define EFOR(i, m, n) for (int i = m; i <= n; i++)
#define RFOR(i, m, n) for (int i = m; i > n; i--)
#define REFOR(i, m, n) for (int i = m; i >= n; i--)
#define VSORT(v) sort((v).begin(), (v).end()) // sort vector
typedef pair<int, int> PI;
typedef tuple<int, int, int> TI;
template <typename T> using Vec = vector<T>; // c++11


int main(void) {
    while (1) {
        int n;
        cin >> n;
        if (n == 0) {
            break;
        }
        Vec<pair<int, string> > table(n);
        int max_count = 0;
        FOR (i, 0, n) {
            string str;
            cin >> str;
            int count = 0;
            int len = str.length();
            int j = 0;
            while (1) {
                if (str[j] == '.') {
                    count++;
                    j++;
                } else {
                    break;
                }
            }
            string rest = str.substr(count, len - count);
            table[i] = make_pair(count, rest);
            max_count = max(max_count, count);
        }

        Vec<Vec<char> > output(n, Vec<char>(max_count + 1, '.'));
        FOR (i, 0, n) {
            output[i][table[i].first] = '+';
        }
        FOR (j, 0, max_count + 1) {
            //cout << "J = " << j << endl;
            int start = -1;
            FOR (i, 0, n) {
                if (output[i][j] == '+') {
                    if (start == -1) {
                        start = i;
                    } else {
                        FOR (k, start, i) {
                            if (output[k][j] == '.') {
                                output[k][j] = '|';
                            }
                        }
                        start = i;
                    }
                } else if (j >= table[i].first) {
                    start = -1;
                }
                //cout << i << " " << start << " " << end << endl;
            }
        }

        cout << table[0].second << endl;
        FOR (i, 1, n) {
            int j = 1;
            while (1) {
                if (output[i][j] == '.') {
                    cout << ' ';
                } else {
                    cout << output[i][j];
                }
                if (output[i][j] == '+') {
                    break;
                }
                j++;
            }
            cout << table[i].second << endl;;
        }
    }
    return 0;
}

Measured memory_bytes: 3964