#include<iostream>
#include<map>
#include<vector>
#include<algorithm>
#include<cmath>
#include<climits>
#include<ctime>
#include<cstring>
#include<stack>
#include<queue>
#include<sstream>
#include<string>
#include<set>
#include<array>

#define ALL(v) (v).begin(),(v).end()
#define REP(i,p,n) for(int i=p;i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define DUMP(list) cout << "{ "; for(auto nth : list){ cout << nth << " "; } cout << "}" << endl
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i);

using namespace std;

int main(){
	while(1){
		int n;
		cin >> n;
		if(n==0) break;
		vector<string> strs(n);
		rep(i,n){
			cin >> strs[i];
		}
		rep(i,n) rep(j,strs[i].size()){
			if(strs[i][j]!='.'){
				if(j>0) strs[i][j-1]='+';
				break;
			}
		}

		rep(i,n) rep(j,strs[i].size()){
			if(strs[i][j]=='+'){
				for(int k=i-1;k>0;k--){
					if(strs[k][j] !='.')break;
					strs[k][j]='|';
				}
			}
		}

		rep(i,n) rep(j,strs[i].size()){
			if(strs[i][j]=='.') strs[i][j] =' ';
		}

		rep(i,n){
			cout << strs[i] << endl;
		}
	}



	return 0;
}