#define _USE_MATH_DEFINES

#include <cstdio>
#include <cstdlib>
#include <string.h>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <map>

using namespace std;

typedef pair<long long int, long long int> P;
long long int INF = 1e18;
long long int MOD = 1000000007;

string str[2000];

int main(){
	while(true){
		int n;
		cin >> n;
		
		if(n == 0){
			break;
		}
		
		for(int i = 0; i < n; i++){
			cin >> str[i];
		}
		
		for(int i = 0; i < n; i++){
			for(int j = 0; j < str[i].size() - 1; j++){
				if(str[i][j] == '.' and str[i][j + 1] != '.'){
					for(int k = i; k >= 0; k--){
						if(str[k][j] == '.'){
							str[k][j] = '|';
						}else{
							break;
						}
					}
				}
			}
		}
		for(int i = 0; i < n; i++){
			for(int j = 0; j < str[i].size() - 1; j++){
				if(str[i][j] == '|' and str[i][j + 1] >= 'a' and str[i][j + 1] <= 'z'){
					str[i][j] = '+';
				}
			}
		}
		
		for(int i = 0; i < n; i++){
			for(int j = 0; j < str[i].size(); j++){
				if(str[i][j] == '.'){
					str[i][j] = ' ';
				}
			}
			cout << str[i] << endl;
		}
	}
	return 0;
}
