#include <bits/stdc++.h>
using namespace std;
struct bracket {
  int rank;
  char symb;
  bracket() {}
  bracket(int r, char s) : rank(r), symb(s) {}
};
int main() {
  ios_base::sync_with_stdio(false);
  int n;
  string brackets, s;
  vector<bracket> v;
  vector<deque<string> > ans;
  cin >> n >> s;
  int crank = 0, max_rank = -1, pic_size = 0;
  for (int i = 0; i < s.length(); i++) {
    if (s[i] == '[')
      v.push_back(bracket(crank, s[i]));
    else
      v.push_back(bracket(crank - 1, s[i]));
    if (s[i] == '[')
      crank++;
    else
      crank--;
    if (crank > max_rank) max_rank = crank;
  }
  max_rank--;
  pic_size = (max_rank + 1) * 2 + 1;
  for (int i = 0; i < v.size(); i++) {
    vector<string> stc;
    deque<string> b;
    string tmp;
    if (v[i].symb == '[')
      tmp = "+-";
    else
      tmp = "-+";
    b.push_back(tmp);
    for (int j = 0; j < (max_rank - v[i].rank) * 2 + 1; j++) {
      b.push_back("|");
    }
    b.push_back(tmp);
    for (int j = 0; j < v[i].rank; j++) {
      b.push_front(" ");
      b.push_back(" ");
    }
    ans.push_back(b);
  }
  int count = 0;
  for (int j = 0; j < pic_size; j++) {
    for (int i = 0; i < ans.size(); i++) {
      cout << ans[i][j];
      if (i + 1 < ans.size() && v[i].symb == '[' && v[i + 1].symb == ']') {
        if (ans[i][j] == "|")
          cout << "   ";
        else {
          cout << " ";
        }
      }
      if (i + 1 < ans.size() && v[i].symb == ']' && v[i + 1].symb == '[' &&
          ans[i][j] == " ")
        cout << "  ";
    }
    cout << endl;
  }
}
