#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <climits>

#define rep(i, m, n) for(int i=int(m);i<int(n);i++)
#define all(c) begin(c),end(c)

template<typename T1, typename T2>
inline void chmin(T1 &a, T2 b) { if (a > b) a = b; }

template<typename T1, typename T2>
inline void chmax(T1 &a, T2 b) { if (a < b) a = b; }

//改造
typedef long long int ll;
using namespace std;
#define INF (1 << 30) - 1
#define INFl (ll)5e15
#define DEBUG 0 //デバッグする時1にしてね
#define dump(x)  cerr << #x << " = " << (x) << endl
#define MOD 1000000007


//ここから編集する
class Solve {
public:
    int N;
    vector<string> s;
    vector<string> raws;
    vector<vector<int>> tree;

    int countDot(string str) {
        int ret = 0;
        for (auto e : str) {
            if (e == '.') ret++;
            else break;
        }
        return ret;
    }

    string rawString(string s) {
        string ret;
        for (auto e : s)
            if (e != '.') ret += e;
        return ret;
    }

    void input() {
        s.resize(N);
        tree.resize(N);
        rep(i, 0, N) cin >> s[i];

        vector<int> ltoid; //ネストの深さをidに
        ltoid.push_back(0);
        for (int i = 1; i < N; ++i) {
            int lv = countDot(s[i]);
            tree[ltoid[lv - 1]].push_back(i);
            if (ltoid.size() - 1 < lv) ltoid.push_back(i);
            else ltoid[lv] = i;
        }
    }

    void rec(int v, int dig, bitset<1001> bit) {
//        bitset<1001> nbit = bit | ((tree[v].size() > 1) << dig);
        bitset<1001> nbit = bit;
        if (tree[v].size() > 1) {
            nbit.set(dig);
        }
        int ndig = dig + 1;

        string str;
        for (int i = 0; i < dig; ++i) {
//            if (bit >> i & 1) {
            if (bit[i]) {
                str += '|';
            } else {
                str += ' ';
            }
        }
        if (dig > 0) {
            str[dig - 1] = '+';
        }
        str += rawString(s[v]);
        cout << str << endl;

//        for (auto nv : tree[v]) {
//            rec(nv, ndig, nbit);
//        }

        for (int i = 0; i < tree[v].size(); ++i) {
            if (i == tree[v].size() - 1) {
//                nbit -= ((tree[v].size() > 1) << dig);
                if (tree[v].size() > 1)
                    nbit.reset(dig);
            }

            int nv = tree[v][i];
            rec(nv, ndig, nbit);

        }


    }

    void solve(int n) {
        N = n;
        input();
        rec(0, 0, bitset<1001>());
    }
};


int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);

//    Solve().solve();
    while (true) {
        int n;
        cin >> n;
        if (n) Solve().solve(n);
        else break;
    }


    return 0;
}



Measured memory_bytes: 4920