#include <bits/stdc++.h>
using namespace std;
const int MAXN = (int)(1e5 + 1e1);
const double PI = acos(-1.0);
int mx, mn, n, h[111];
char c;
vector<string> res(0);
int main() {
  cin >> n;
  int a = n / 2 + 1;
  for (int i = 0; i < n; ++i) {
    int t = 0;
    cin >> c;
    if (c == '[') {
      a--;
      h[i] = a;
    } else {
      a++;
      h[i] = -1 * (a - 1);
    }
  }
  for (int i = 0; i < n; ++i) {
    if (h[i] > h[mx]) mx = i;
    if (abs(h[i]) < abs(h[mn])) mn = i;
  }
  mx = (h[mx] - h[mn]) * 2 + 1;
  mn = h[mn];
  for (int i = 0; i < n; ++i) {
    string s = "";
    int is = 0;
    if (i - 1 >= 0 && i + 1 < n &&
        (abs(h[i - 1]) > abs(h[i]) || abs(h[i + 1]) > abs(h[i])))
      is = 1;
    for (int j = 0; j < (mx - (abs(h[i]) - mn) * 2 - 1) / 2 - is; ++j) s += " ";
    if (is == 1) s += '-';
    s += '+';
    for (int j = 0; j < (abs(h[i]) - mn) * 2 + 1; ++j) s += '|';
    s += '+';
    if (is == 1) s += '-';
    for (int j = 0; j < (mx - (abs(h[i]) - mn) * 2 - 1) / 2 - is; ++j) s += " ";
    res.push_back(s);
    if (i + 1 < n && h[i] == abs(h[i + 1])) {
      string t = "", g = "";
      for (int j = 0; j < mx + 2; ++j) t += " ";
      for (int i = 0; i < s.length(); ++i)
        if (s[i] == '+')
          g += '-';
        else
          g += " ";
      res.push_back(g);
      res.push_back(t);
      res.push_back(g);
    }
  }
  for (int j = 0; j < res[0].size(); ++j) {
    for (int i = 0; i < res.size(); ++i) cout << res[i][j];
    cout << '\n';
  }
  return 0;
}
