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

#define rep(i, n) for(int i = 0; i < int(n) ;++i)
#define SZ(a) ((int)(a.size()))
int n;

string in[10000];

void solve(){
  rep(i, n) cin >> in[i];
  rep(i, n){
    int idx = -1;
    rep(j, SZ(in[i])){
      if(in[i][j] != '.'){
        if(j){
          in[i][j - 1] = '+';
          idx = j - 1;
        }
        break;
      }
    }
    if(idx >= 0)for(int k = i - 1; k; --k){
      if(isalpha(in[k][idx]) || in[k][idx] == '+') break;
      in[k][idx] = '|';
    }
  }
  rep(i, n) for(auto& c : in[i]) if(c == '.') c = ' ';
  rep(i, n) cout << in[i] << endl;
}

int main(int argc, char *argv[])
{

  while(cin >> n && n) solve();
  return 0;
}