#include <bits/stdc++.h>
using namespace std;
vector<string> screen(1000, string(1000, ' '));
int main() {
  int n;
  string s;
  cin >> n >> s;
  int maxdep = 0;
  int curdep = 0;
  for (int i = 0; i < n; i++) {
    if (s[i] == '[')
      curdep++;
    else
      curdep--;
    maxdep = max(maxdep, curdep);
  }
  int pos = 0;
  int dep = 0;
  for (int i = 0; i < n; i++) {
    if (s[i] == '[') {
      dep++;
      screen[dep - 1][pos] = '+';
      screen[dep - 1][pos + 1] = '-';
      screen[2 * maxdep - dep + 1][pos] = '+';
      screen[2 * maxdep - dep + 1][pos + 1] = '-';
      for (int i = dep; i < 2 * maxdep - dep + 1; i++) screen[i][pos] = '|';
      pos++;
    } else if (s[i] == ']') {
      if (s[i - 1] == '[') pos += 3;
      screen[dep - 1][pos] = '+';
      screen[dep - 1][pos - 1] = '-';
      screen[2 * maxdep - dep + 1][pos] = '+';
      screen[2 * maxdep - dep + 1][pos - 1] = '-';
      for (int i = dep; i < 2 * maxdep - dep + 1; i++) screen[i][pos] = '|';
      pos++;
      dep--;
    }
  }
  for (int i = 0; i <= 2 * maxdep; i++) {
    for (int j = 0; j < pos; j++) cout << screen[i][j];
    cout << endl;
  }
}
