#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  string s;
  cin >> n >> s;
  int maxDepth = 0;
  int d = 0;
  for (int i = 0; i < n; i++) {
    if (s[i] == '[') {
      d++;
      maxDepth = max(maxDepth, d);
    } else {
      d--;
    }
  }
  vector<string> res;
  int tr = 0;
  d = maxDepth;
  int tam = maxDepth * 2 + 1;
  for (int i = 0; i < n; i++) {
    if (s[i] == '[') {
      if (i > 0 && s[i - 1] == '[') {
        int yo = d * 2 + 1;
        string b(tam, ' ');
        for (int j = 0; j < yo; j++) {
          int p = j + (tam - yo) / 2;
          if (j == 0 || j + 1 == yo) {
            res[tr - 1][p] = '+';
            b[p] = '-';
          } else {
            res[tr - 1][p] = '|';
          }
        }
        res.push_back(b);
        tr++;
      } else {
        int yo = d * 2 + 1;
        string a(tam, ' ');
        string b(tam, ' ');
        for (int j = 0; j < yo; j++) {
          int p = j + (tam - yo) / 2;
          if (j == 0 || j + 1 == yo) {
            a[p] = '+';
            b[p] = '-';
          } else {
            a[p] = '|';
          }
        }
        res.push_back(a);
        res.push_back(b);
        tr += 2;
      }
      d--;
    } else {
      d++;
      if (s[i - 1] == '[') {
        res.push_back(string(tam, ' '));
        tr++;
        int yo = d * 2 + 1;
        string a(tam, ' ');
        string b(tam, ' ');
        for (int j = 0; j < yo; j++) {
          int p = j + (tam - yo) / 2;
          if (j == 0 || j + 1 == yo) {
            a[p] = '+';
            b[p] = '-';
          } else {
            a[p] = '|';
          }
        }
        res.push_back(b);
        res.push_back(a);
        tr += 2;
      } else {
        int yo = d * 2 + 1;
        string b(tam, ' ');
        for (int j = 0; j < yo; j++) {
          int p = j + (tam - yo) / 2;
          if (j == 0 || j + 1 == yo) {
            b[p] = '+';
            res[tr - 1][p] = '-';
          } else {
            b[p] = '|';
          }
        }
        res.push_back(b);
        tr++;
      }
    }
  }
  for (int i = 0; i < res[0].size(); i++) {
    for (int j = 0; j < res.size(); j++) {
      cout << res[j][i];
    }
    cout << endl;
  }
  return 0;
}
