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

int main(){
    for (int n; cin >> n, n;) {
        vector<string> s(n);
        rep(i, n) {
            cin >> s[i];
            auto pos = s[i].find_last_of('.');
            if (pos == string::npos) continue;
            fill_n(s[i].begin(), pos, ' ');
            s[i][pos] = '+';
            for (int j = i - 1; j >= 0 && s[j][pos] == ' '; --j) s[j][pos] = '|';
        }
        for (auto& e : s) cout << e << endl;
    }
}