#include <bits/stdc++.h>
using namespace std;

using ll = long long int;
using ull = unsigned long long int;
using P = pair<ll, ll>;
using P3 = pair<P,ll>;
using PP = pair<P, P>;
constexpr int INF = 1 << 30;
constexpr ll MOD = ll(1e9)+7;
constexpr int di[] = {0, 1, 1, 1, 0, -1, -1, -1};
constexpr int dj[] = {1, 1, 0, -1, -1, -1, 0, 1};
constexpr double EPS = 1e-9;

int solve(){
    int n;
    cin >> n;
    if(n==0) return 1;
    vector<string> s(n);
    for(int i=0;i<n;i++){
        cin >> s[i];
    }
    for(int i=0;i<n;i++){
        int m = s[i].size();
        for(int j=0;j<m-1;j++){
            if(s[i][j] != '.') break;
            if(isalpha(s[i][j+1])){
                s[i][j] = '+';
                break;
            }
            else s[i][j] = ' '; 
        }
    }
    for(int i=0;i<n;i++){
        int j = 0;
        while(s[i][j] == ' ' || s[i][j] == '|') j++;
        if(s[i][j] != '+') continue;
        int ni = i+1;
        while(ni<n && j<s[ni].size() && isblank(s[ni][j])) ni++;
        if(ni<n && j<s[ni].size() && s[ni][j] == '+'){
            for(int k=i+1;k<ni;k++){
                s[k][j] = '|';
            }
        }   
    }
    for(int i=0;i<n;i++){
        cout << s[i] << endl;
    }
    return 0;
}

int main(){
    while(solve()==0);
    // solve();
    return 0;
}

