#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>

#include <iostream>
#include <complex>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>

#include <functional>
#include <cassert>

typedef long long ll;
using namespace std;

#define debug(x) cerr << __LINE__ << " : " << #x << " = " << (x) << endl;

#define mod 1000000007 //1e9+7(prime number)
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define SIZE 100010

bool solve(){
  int n;
  string s[1000];
  cin >> n;

  if(n == 0) return false;

  int prevLevel = -1;
  
  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();j++){
      if(s[i][j] != '.') break;
      
      if(s[i][j+1] != '.'){
        s[i][j] = '+';
        for(int k=i-1;k>=0;k--){
          if(s[k][j] == ' ') s[k][j] = '|';
          else break;
        }
      }else{
        s[i][j] = ' ';
      }
    }
  }

  for(int i=0;i<n;i++){
    cout << s[i] << endl;
  }
  
  return true;
}

int main(){
  while(solve());
  
  return 0;
}

