/*
 * 2583.cc: JAG-channel
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

const int MAX_N = 1000;

/* typedef */

/* global variables */

string ss[MAX_N];

/* subroutines */

/* main */

int main() {
  for (;;) {
    int n;
    cin >> n;
    if (n == 0) break;

    for (int i = 0; i < n; i++) cin >> ss[i];

    for (int i = 1; i < n; i++) {
      string &si = ss[i];
      int k = 0;
      si[0] = ' ';
      while (si[k + 1] == '.') si[k++] = ' ';
      si[k] = '+';
      for (int j = i - 1; j >= 0 && ss[j][k] == ' '; j--)
	ss[j][k] = '|';
    }

    for (int i = 0; i < n; i++) cout << ss[i] << endl;
  }

  return 0;
}