#include <iostream>
#include <cstdio>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <algorithm>
#include <cstring>
#include <functional>
#include <cmath>
#include <complex>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);++i)
#define rep1(i,n) for(int i=1;i<=(n);++i)
#define all(c) (c).begin(),(c).end()
#define fs first
#define sc second
#define pb push_back
#define show(x) cout << #x << " " << x << endl
string s[1000];
int main(){
	while(true){
		int N;
		cin>>N;
		if(N==0) break;
		rep(i,N) cin>>s[i];
		int m=0;
		rep1(i,N-1){
			int j=0;
			while(s[i][j]=='.') j++;
			j--;
			s[i][j]='+';
			m=max(m,j);
		}
		rep(i,m){
			int p=-1;
			rep(j,N){
				if(s[j].size()<=i) continue;
				if(s[j][i]=='+'){
					if(p==-1){
						p=j;
					}else{
						for(int k=p+1;k<j;k++) s[k][i]='|';
						p=j;
					}
				}else{
					if(s[j][i]!='.') p=-1;
				}
			}
		}
		rep(i,N){
			rep(j,s[i].size()) if(s[i][j]=='.') s[i][j]=' ';
			cout<<s[i]<<endl;
		}
	}
}