#include <bits/stdc++.h>
using namespace std;
int n;
string s;
vector<int> level;
vector<string> ans;
int d;
void run() {
  level.resize(n);
  d = 0;
  for (int i = 0, j = 0; i < n; ++i) {
    if (s[i] == '[') {
      ++j;
      level[i] = j;
      d = max(d, j);
    } else {
      level[i] = j;
      --j;
    }
  }
  for (int i = 0; i < n; ++i) {
    level[i] = d + 1 - level[i];
  }
}
void print_open(int pos, int h) {
  ans[d][pos] = '|';
  for (int i = 1; i < h; ++i) {
    ans[d - i][pos] = '|';
    ans[d + i][pos] = '|';
  }
  ans[d - h][pos] = '+';
  ans[d + h][pos] = '+';
  ans[d - h][pos + 1] = '-';
  ans[d + h][pos + 1] = '-';
}
void print_closed(int pos, int h) {
  ans[d][pos] = '|';
  for (int i = 1; i < h; ++i) {
    ans[d - i][pos] = '|';
    ans[d + i][pos] = '|';
  }
  ans[d - h][pos] = '+';
  ans[d + h][pos] = '+';
  ans[d - h][pos - 1] = '-';
  ans[d + h][pos - 1] = '-';
}
int main() {
  cin >> n >> s;
  run();
  int len = n;
  for (int i = 1; i < n; ++i) {
    if (s[i - 1] == '[' && s[i] == ']') {
      len += 3;
    }
  }
  ans.assign(2 * d + 1, std::string(len, ' '));
  for (int i = 0, j = 0; i < n; ++i, ++j) {
    if (i > 0 && s[i - 1] == '[' && s[i] == ']') {
      j += 3;
    }
    if (s[i] == '[') {
      print_open(j, level[i]);
    } else {
      print_closed(j, level[i]);
    }
  }
  for (int i = 0; i < ans.size(); ++i) cout << ans[i] << endl;
  return 0;
}
