#include <iostream>
#include <string>

using namespace std;

int main()
{
	int n;
	while (cin >> n && n){
		string s[1001];
		for (int i = 0; i < n; i++)
			cin >> s[i];

		for (int i = 0; i < n; i++){
			for (int j = 0; j < s[i].size() - 1; j++){
				if (s[i][j] == '.' && s[i][j + 1] != '.'){
					s[i][j] = '+'; break;
				}
			}
		}
		for (int i = 0; i < n; i++){
			for (int j = 0; j < s[i].size(); j++){
				if (s[i][j] >= 'a' && s[i][j] <= 'z'){

					int t = -1;
					for (int k = i + 1; k < n; k++){
						if (j >= s[k].size())break;
						if (s[k][j] == '+'){
							t = k;
						}
						else
						if (s[k][j] == '.'){
							s[k][j] = ' ';
						}
						else break;
					}
					for (int k = t; k > i; k--){
						if (s[k][j] == ' ')
							s[k][j] = '|';
					}
					break;
				}
			}
		}
		for (int i = 0; i < n; i++){
			cout << s[i] << endl;
		}

	}
	return 0;
}