#include <bits/stdc++.h>
#define ll long long
#define vl vector<ll>
#define pl pair<ll,ll>
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,b) for(ll i=0;i<b;i++)
#define RFOR(i,a,b) for(ll i=b-1;i>=a;i--)
#define rsort(v) sort((v).rbegin(), (v).rend())
#define all(v) (v).begin(),(v).end()
using namespace std;

ll mod=1000000007;
signed main() {
    ll n;
    while(cin>>n,n){
        string s[n];
        rep(i,n)cin>>s[i];
        RFOR(i,1,n)
            rep(j,s[i].size()-1)
        if(s[i][j]=='.'&&s[i][j+1]<='z'&&s[i][j+1]>='a'){
            s[i][j]='+';
            ll k=i;
            while(s[k-1][j]=='.') if(s[k--][j]!='+')s[k+1][j]='|';
            s[k][j]='+';
        }
        RFOR(i,1,n)
            rep(j,s[i].size()-1)
        if(s[i][j]=='|'&&s[i][j+1]<='z'&&s[i][j+1]>='a') s[i][j]='+';
        RFOR(i,1,n)
            rep(j,s[i].size()-1)
        if(s[i][j]=='.') s[i][j]=' ';
        rep(i,n)cout<<s[i]<<endl;
    }
}
