#include <bits/stdc++.h>
using namespace std;

int main()
{
	int n;
	while (cin >> n, n) {
		vector<string> s(n), res(n);
		vector<int> cnt(n);
		for (int i = 0; i < n; i++) {
			cin >> s[i];
			for (auto c : s[i]) {
				if (c == '.') {
					cnt[i]++;
				}
			}
		}
		for (int i = 1; i < n; i++) {
			if (cnt[i]) {
				s[i][cnt[i] - 1] = '+';
			}
		}
		for (int i = 1; i < n; i++) {
			if (cnt[i] < cnt[i - 1]) {
				for (int j = i - 1; cnt[j] > cnt[i]; j--) {
					s[j][cnt[i] - 1] = '|';
				}
			}
		}
		for (int i = 1; i < n; i++) {
			for (int j = 0; j < cnt[i]; j++) {
				if (s[i][j] == '.') {
					s[i][j] = ' ';
				}
			}
		}
		for (auto ss : s) {
			cout << ss << endl;
		}
	}
	return 0;
}