#include <bits/stdc++.h>
using namespace std;
const long long N = 105;
long long A[N];
string v[3 * N];
string t;
void pub(string &s, long long i, char c) {
  if (i == 0)
    s.push_back(c);
  else if (t[i - 1] == '[')
    s[s.size() - 1] = c;
  else
    s.push_back(c);
}
void solve() {
  long long n;
  stack<long long> s;
  cin >> n;
  cin >> t;
  long long dep = 0;
  for (__typeof(((long long)t.size() - 1)) i = (0);
       i <= ((long long)t.size() - 1); i++) {
    if (t[i] == '[') {
      if (s.empty()) {
        s.push(0);
        A[i] = s.top();
      } else {
        s.push(s.top() + 1);
        A[i] = s.top();
      }
      dep = max(dep, s.top());
    } else {
      A[i] = s.top();
      s.pop();
    }
  }
  long long c = (2 * dep + 1 + 2) / 2;
  long long upMax = 0;
  long long downMax = 2 * (dep) + 2;
  for (__typeof(((long long)t.size() - 1)) i = (0);
       i <= ((long long)t.size() - 1); i++) {
    long long h = 2 * (dep - A[i]) + 1;
    if (t[i] == ']') {
      long long q = dep - A[i];
      if (t[i - 1] == '[') {
        for (__typeof((downMax)) j = (upMax); j <= (downMax); j++) {
          v[j].push_back(' ');
          v[j].push_back(' ');
        }
      }
      v[c - q - 1][v[c - q - 1].size() - 1] = '-';
      v[c - q - 1].push_back('+');
      v[c + q + 1][v[c + q + 1].size() - 1] = '-';
      v[c + q + 1].push_back('+');
      for (long long j = c - q; j <= c + q; j++) {
        v[j].push_back('|');
      }
      for (long long j = c - q - 2; j >= upMax; j--) v[j].push_back(' ');
      for (long long j = c + q + 2; j <= downMax; j++) v[j].push_back(' ');
    } else {
      pub(v[c], i, '|');
      long long q = dep - A[i];
      long long j = c - 1;
      for (; q > 0; q--) {
        pub(v[j], i, '|');
        j--;
      }
      pub(v[j], i, '+');
      v[j].push_back('-');
      long long x1 = j;
      j--;
      if (i - 1 < 0 or t[i - 1] == ']') {
        for (; j >= upMax; j--) pub(v[j], i, ' ');
      }
      j = c + 1;
      q = dep - A[i];
      for (; q > 0; q--) {
        pub(v[j], i, '|');
        j++;
      }
      pub(v[j], i, '+');
      v[j].push_back('-');
      long long x2 = j;
      j++;
      if (i - 1 < 0 or t[i - 1] == ']') {
        for (; j <= downMax; j++) v[j].push_back(' ');
      }
      for (long long j = upMax; j <= downMax; j++) {
        if (j == x1 or j == x2) continue;
        v[j].push_back(' ');
      }
    }
  }
  for (long long i = upMax; i <= downMax; i++) cout << v[i] << '\n';
}
signed main() {
  long long t;
  ios_base::sync_with_stdio(false);
  t = 1;
  while (t--) solve();
  return 0;
}
