#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  string s;
  cin >> s;
  vector<int> brack(n);
  vector<char> dir(n, 0);
  int lev = 0;
  int maxim = 0;
  for (int i = 0; i < n; i++) {
    if (s[i] == '[') {
      dir[i] = 1;
      brack[i] = lev;
      lev++;
      maxim = max(lev, maxim);
    }
    if (s[i] == ']') {
      lev--;
      brack[i] = lev;
    }
  }
  for (int i = 0; i < n; i++) brack[i] = maxim - brack[i];
  vector<int> count(n);
  count[0] = 0;
  for (int i = 1; i < n; i++) {
    if (dir[i - 1] == 1 && dir[i] == 0 && brack[i - 1] == brack[i])
      count[i] = count[i - 1] + 4;
    else
      count[i] = count[i - 1] + 1;
  }
  for (int i = maxim; i > -1; i--) {
    int pos = 0;
    for (int j = 0; j < n; j++) {
      for (pos; pos < count[j] - !dir[j]; pos++) cout << ' ';
      if (brack[j] == i) {
        if (dir[j])
          cout << "+-";
        else
          cout << "-+";
        pos += 2;
      } else if (brack[j] > i) {
        if (dir[j - 1] == 1 && dir[j] == 0 && brack[j - 1] == brack[j]) {
          cout << " |";
          pos++;
        } else
          cout << '|';
        pos++;
      }
    }
    cout << endl;
  }
  for (int i = 1; i <= maxim; i++) {
    int pos = 0;
    for (int j = 0; j < n; j++) {
      for (pos; pos < count[j] - !dir[j]; pos++) cout << ' ';
      if (brack[j] == i) {
        if (dir[j])
          cout << "+-";
        else
          cout << "-+";
        pos += 2;
      } else if (brack[j] > i) {
        if (dir[j - 1] == 1 && dir[j] == 0 && brack[j - 1] == brack[j]) {
          cout << " |";
          pos++;
        } else
          cout << '|';
        pos++;
      }
    }
    cout << endl;
  }
  return 0;
}
