#include<cstdio>
using namespace std;

int main() {
  int n;
  char s[1000][1060];
  int counter[1000];
  while (1) {
    scanf("%d", &n);
    if (n == 0) return 0;
    for (int i = 0; i < n; i++) scanf("%s", s[i]);
    for (int i = 0; i < n; i++)
      for (counter[i] = 0; s[i][counter[i]] == '.'; counter[i]++) s[i][counter[i]] = ' ';
    for (int i = 0; i < n; i++) counter[i]--;
    printf("%s\n", s[0]);
    for (int i = 1; i < n; i++) {
      s[i][counter[i]] = '+';
      if (counter[i - 1] > counter[i]) {
        for (int j = i - 1; counter[j] > counter[i]; j--) s[j][counter[i]] = '|';
      }
    }
    for (int i = 1; i < n; i++) printf("%s\n", s[i]);
  }
}

