#include <bits/stdc++.h>
using namespace std;
const int N = 111;
char f[N][10 * N];
char buf[10 * N];
int get_len(string s) {
  int res = s.size();
  char p = ' ';
  for (char c : s) {
    if (c == ']' && p == '[') res += 3;
    p = c;
  }
  return res;
}
void solve() {
  int n;
  scanf("%d", &n);
  scanf(" %s", buf);
  string s(buf);
  int len = get_len(s);
  int i = 0;
  bool ok;
  do {
    ok = false;
    fill(f[i], f[i] + len, ' ');
    int cur = 0;
    int pt = 0;
    char pr = '-';
    for (char c : s) {
      if (c == '[') {
        if (cur == i) {
          f[i][pt] = '+';
          f[i][pt + 1] = '-';
          ok = true;
        } else if (cur < i)
          f[i][pt] = '|';
        pt++;
        cur++;
      } else {
        --cur;
        if (pr == '[') pt += 3;
        if (cur == i) {
          f[i][pt - 1] = '-';
          f[i][pt] = '+';
          ok = true;
        } else if (cur < i)
          f[i][pt] = '|';
        pt++;
      }
      pr = c;
    }
    ++i;
  } while (ok);
  for (int j = 0; j < i; ++j) puts(f[j]);
  for (int j = i - 2; j >= 0; --j) puts(f[j]);
}
int main() { solve(); }
