#include <bits/stdc++.h>
using namespace std;
const int N = 320;
int enc[N];
int curenc[N];
char f[N][N];
int depth[N];
int main() {
  int n;
  cin >> n;
  string s;
  cin >> s;
  vector<int> opens;
  int mxEnc = 0;
  for (int i = 0; i < n; ++i) {
    if (s[i] == '[') {
      opens.push_back(i);
      for (int br : opens) {
        ++curenc[br];
        enc[br] = max(enc[br], curenc[br]);
        mxEnc = max(mxEnc, enc[br]);
      }
      depth[i] = opens.size() - 1;
    } else {
      depth[i] = depth[opens.back()];
      opens.pop_back();
      for (int br : opens) --curenc[br];
    }
  }
  for (int i = 0; i < N; ++i) fill(f[i], f[i] + N, ' ');
  int cx = 0;
  for (int i = 0; i < n; ++i) {
    int yfrom = depth[i], cenc = mxEnc - depth[i];
    if (s[i] == '[') {
      if (i > 0 && s[i - 1] == ']') ++cx;
      f[yfrom][cx] = '+';
      f[yfrom + 2 * cenc][cx] = '+';
      f[yfrom][cx + 1] = '-';
      f[yfrom + 2 * cenc][cx + 1] = '-';
      for (int j = yfrom + 1; j <= yfrom + 2 * cenc - 1; ++j) f[j][cx] = '|';
      ++cx;
    } else {
      if (s[i - 1] == '[') cx += 2;
      f[yfrom][cx] = '-';
      f[yfrom + 2 * cenc][cx] = '-';
      f[yfrom][cx + 1] = '+';
      f[yfrom + 2 * cenc][cx + 1] = '+';
      ++cx;
      for (int j = yfrom + 1; j <= yfrom + 2 * cenc - 1; ++j) f[j][cx] = '|';
    }
  }
  for (int i = 0; i <= 2 * mxEnc; ++i) {
    for (int j = 0; j <= cx; ++j) cout << f[i][j];
    cout << '\n';
  }
  return 0;
}
