#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <vector>
#include <stack>
#include <queue>

#define REP(i,n)for (int i=0;i<(n);i++)
#define PB push_back
#define MP make_pair
#define ALL(a) (a).begin(),(a).end()
#define ll long long
using namespace std;
typedef pair<int,int> P;

int main(){
	int n;
	string s[1024];
	while(1){
		cin>>n;
		if(n==0)break;
		REP(i,n)cin>>s[i];
		REP(i,n){
			int c=0;
			while(s[i][c]=='.'){
				s[i][c]=' ';
				c++;
			}
			if(c==0)continue;
			s[i][--c]='+';
			for(int j=i-1;j>=0&&s[j][c]==' ';j--){
				s[j][c]='|';
			}
		}
		REP(i,n)cout<<s[i]<<endl;
	}
}
