#include <bits/stdc++.h>
using namespace std;
using Int = long long;
void solve(int N, vector<string>& S)
{
    vector<string> T(N);
    vector<vector<int>> G(N+1);
    vector<int> items = {0};
    for (int i = 0; i < N; i++) {
        int level = 0;
        while (S[i][level] == '.') level++;
        while (items.size() > level + 1) items.pop_back();
        G[items.back()].push_back(i+1);
        items.push_back(i+1);
        T[i] = S[i].substr(level);
    }
    function<void(int, string)> recur = [&](int id, string acc) {
        if (id != 0) {
            if (acc.size() == 1) {
                cout << T[id-1] << '\n';
            } else {
                for (int j = 1; j < acc.size()-1; j++) {
                    cout << acc[j];
                }
                cout << '+' << T[id-1] << '\n';
            }
        }
        for (int i = 0; i < G[id].size(); i++) {
            if (i + 1 < G[id].size()) {
                recur(G[id][i], acc + '|');
            } else {
                recur(G[id][i], acc + ' ');
            }
        }
    };
    recur(0, "");
}

int main()
{
    int N;
    for (;;) {
        cin >> N;
        if (N == 0) break;
        vector<string> S(N); for (auto &s : S) cin >> s;
        solve(N, S);
    }
    return 0;
}
