#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i, a, b) for (int i = (int)(a); i < (int)(b); ++i)
#define all(c) c.begin(),c.end()
#define sz(c) ((int)c.size())
using pii = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vector<int>>;

signed main() {
    while (1) {
        int n;
        cin >> n;
        if (n == 0) break;

        vector<string> s(n);
        rep(i, 0, n) {
            cin >> s[i];
        }
        rep(i, 0, n) {
            if (s[i][0] != '.') continue;
            rep(j, 0, sz(s[i]) - 1) {
                if (s[i][j + 1] != '.') {
                    int r = i - 1;
                    while (r >= 0 && s[r][j] == '.') {
                        s[r][j] = '|';
                        r--;
                    }
                    s[i][j] = '+';
                    break;
                }
            }
        }
        rep(i, 0, n) {
            rep(j, 0, sz(s[i])) {
                if (s[i][j] == '.') s[i][j] = ' ';
            }
            cout << s[i] << endl;
        }
    }
}

