#include<iostream>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<utility>
#include<vector>
#include<cmath>
#include<cstdio>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define all(in) in.begin(),in.end()
const double PI=acos(-1);
const double ESP=1e-10;
using namespace std;
int main(){
  int n;
  while(cin>>n,n){
    vector<string>in(n);
    rep(i,n)cin>>in[i];
    map<int,vector<int> >tmp;
    rep(i,n){
      rep(j,in[i].size())if(in[i][j]!='.'){
	if(j){
	  in[i][j-1]='+';
	  tmp[j].pb(i);
	}
	break;
      }else in[i][j]=' ';
    }

    map<int,vector<int> >::iterator it=tmp.begin();
    for(;it!=tmp.end();it++){
      int d=it->first;
      rep(i,tmp[d].size()-1){
	if(tmp[d][i+1]-tmp[d][i]<2)continue;
	bool h=true;
	loop(j,tmp[d][i],tmp[d][i+1])if(isalpha(in[j][d-1]))h=false;
	if(h)loop(j,tmp[d][i]+1,tmp[d][i+1])in[j][d-1]='|';
      }
    }
    rep(i,n)cout<<in[i]<<endl;
  }
}