#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cmath>
#define int long long
#define mod 1000000007
#define for0(i, n) for(int i = 0; i < (n); i++)
#define for1(i, n) for(int i = 1; i <= (n);i++)
using namespace std;
int get() { int r; cin >> r; return r; }
int n;
string s[1010];
bool b[2000];
signed main() {
	while (cin >> n, n) {
		for0(i, 1500)b[i] = 0;
		for1(i, n)cin >> s[i];
		for (int i = n; i >= 1; i--) {
			int j;
			for (j = 0; s[i][j] == '.'; j++) {
				if (s[i][j + 1] != '.') {
					s[i][j] = '+';
					b[j] = 1;
				}
				else s[i][j] = (b[j] ? '|' : ' ');
			}
			for (; j <= 1500; j++)b[j] = 0;
		}
		for1(i, n)cout << s[i] << endl;
	}
}
