#include <iostream>
#include <string>
#include <stdio.h>
#include <vector>
#include <bitset>

using namespace std;

struct node {
	string mes;
	int depth;
};

node deldots( node n ) {
	node ret;
	int cnt = 0;
	for(int i = 0; i < n.mes.length(); i++) {
		if( n.mes[i] == '.' ) {
			ret.mes += " ";
			cnt ++;
		}
		else ret.mes += n.mes[i];
	}
	if( cnt > 0 )
		ret.mes[cnt-1] = '+';
	ret.depth = cnt - 1;
	return ret;
}

int main(void){

	while( 1 ) {
		int n;
		vector< node > v;
		bitset< 1 << 20 > b;
		b.reset();

		cin >> n;
		if( n == 0 ) break;
		
		for(int i = 0; i < n; i++) {
			node str;
			cin >> str.mes;
			str = deldots( str );
			v.push_back( str );
		}

		for(int i = 0; i < n; i++) {
			if( v[i].depth >= 0 ) {
				b.reset( v[i].depth );
				for(int j = 0; j < v[i].mes.length(); j++) {
					if( b[j] )
						cout << "|";
					else
						cout << v[i].mes[j];
				}
				cout << endl;
				for(int j = i + 1; j < n; j++) {
					if( v[i].depth > v[j].depth ) {
						break;
					} else if( v[i].depth == v[j].depth ) {
						b.set( v[i].depth );
					}
				}
			} else {
				cout << v[i].mes << endl;
			}
		}

		
	}
	return 0;
}