#include <bits/stdc++.h>
using namespace std;
int main() {
  string s;
  int k;
  cin >> k;
  cin >> s;
  vector<int> b;
  int max = 0, balance = 1, counter = 1;
  b.push_back(0);
  for (int i = 1; i < s.size(); i++) {
    max = balance > max ? balance : max;
    b.push_back(0);
    counter++;
    if (s[i] == '[') {
      balance++;
    } else {
      balance--;
    }
  }
  int sz = 1 + 2 * (max - 1) + 2;
  for (int j = 0; j < sz; j++) {
    for (int i = 0; i < s.size(); i++) {
      if (s[i] == '[') {
        balance++;
        if (balance == j + 1 || balance == sz - j) {
          cout << "+-";
          b[i]++;
        } else {
          if (balance > j + 1 || b[i] == 2)
            s[i - 1] == ']' ? cout << "   " : cout << " ";
          else
            cout << "|";
        }
      }
      if (s[i] == ']') {
        balance--;
        if (balance == j || balance == sz - j - 1) {
          s[i - 1] == '[' ? cout << " -+" : cout << "-+";
          b[i]++;
        } else {
          if (balance > j || b[i] == 2)
            s[i - 1] == '[' ? cout << "  " : cout << " ";
          else
            s[i - 1] == '[' ? cout << "   |" : cout << "|";
        }
      }
    }
    if (j != sz - 1) cout << endl;
  }
}
