#include <iostream>
#include <complex>
#include <sstream>
#include <string>
#include <algorithm>
#include <deque>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <vector>
#include <set>
#include <limits>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <ctime>
using namespace std;
#define REP(i, j) for(int i = 0; i < (int)(j); ++i)
#define FOR(i, j, k) for(int i = (int)(j); i < (int)(k); ++i)
#define SORT(v) sort((v).begin(), (v).end())
#define REVERSE(v) reverse((v).begin(), (v).end())
typedef complex<double> P;

int N, L;

int main() {
  while(cin >>N && N){
    vector<string> v(N);
    REP(i, N){
      cin >>v[i];
      L = max(L, (int)v[i].length());
    }
    REP(i, N) FOR(j, 1, v[i].length()) if(v[i][j - 1] == '.' && isalpha(v[i][j])) v[i][j - 1] = '+';
    REP(l, L){
      bool f = 0;
      for(int i = N - 1; i >= 0; --i){
        if(l >= v[i].length()) continue;
        if(!f){
          if(v[i][l] == '+') f = 1;
          else f = 0;
        } else{
          if(v[i][l] == '.') v[i][l] = '|';
          else if(v[i][l] != '+') f = 0;
        }
      }
    }
    REP(i, N){
      REP(j, v[i].length()) if(v[i][j] == '.') v[i][j] = ' ';
      cout <<v[i] <<endl;
    }
  }
  return 0;
}