#include <cstdio>
#include <cstdlib>
#include <string>
#include <cmath>
#include <cassert>
#include <iostream>
#include <sstream>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <numeric>
#include <algorithm>
#include <bitset>
#include <complex>

using namespace std;

typedef unsigned uint;
// typedef long long Int;

const int INF = 1001001001;
// const Int INFLL = 1001001001001001001LL;

int main(void)
{
	int n, i, j, k;
	static char str [1024][2048];
	
	while (1){
		scanf("%d", &n);
		if (n == 0)break;
		
		for (i = 0; i < n; i++){
			scanf("%s", str[i]);
		}
		
		for (i = 1; i < n; i++){
			for (j = 0; str[i][j] != '\0'; j++){
				if (str[i][j] == '.'){
					if ('a' <= str[i][j + 1] && str[i][j + 1] <= 'z'){
						str[i][j] = '+';
					}
				}
			}
		}
		
		for (i = n - 1; i > 0; i--){
			k = 1;
			j = 0;
			while (1){
				if (str[i][j] == '+')break;
				j++;
			}
			while (str[i - k][j] == '.'){
				
				str[i - k][j] = '|';
				k++;
			}
		}
		
		for (i = 0; i < n; i++){
			for (j = 0; str[i][j] != '\0'; j++){
				if (str[i][j] == '.') str[i][j] = ' ';
			}
		}
		
		for (i = 0; i < n; i++){
			printf("%s\n", str[i]);
		}
	}
	
	return (0);
}