#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int (i)=(0);(i)<(int)(n);++(i))
using ll = long long;
using P = pair<int, int>;
using namespace std;

template<class T> void vin(vector<T>& v, int n) {
    v.resize(n);
    for (int i = 0; i < n; ++i) {
        cin >> v[i];
    }
}

string str[2020];

int main() {
    int n;
    while (cin >> n, n) {
        rep(i, n) cin >> str[i];
        rep(i, n) {
            int a = 0;
            while (a < str[i].size() and str[i][a] == '.') str[i][a++] = ' ';
            if (!a) continue;
            str[i][--a] = '+';
            int b = i-1;
            while (b >= 0 and a < str[b].size() and str[b][a] == ' ') str[b--][a] = '|';
        }
        rep(i, n) {
            cout << str[i] << endl;
        }
    }
}

