#include <bits/stdc++.h>
const long long int mrx = 1e6 + 5, M = 1e9 + 7, dm = 1e3 + 5;
long long int mx = -1e18, mn = 1e18;
using namespace std;
long long int n, k;
string s, d[dm];
long long int id1, id2;
int main() {
  cin >> n >> s;
  for (long long int i = 0; i < s.size(); ++i) {
    if (s[i] == '[') {
      k++;
      mx = max(k, mx);
    } else {
      k--;
    }
  }
  mx *= 2;
  mx--;
  d[0] += "+-";
  d[mx + 1] += "+-";
  for (long long int i = 1; i < mx + 1; ++i) {
    d[i] += "|";
  }
  id1 = 0;
  id2 = mx + 1;
  for (long long int j = 1; j < s.size(); ++j) {
    if (s[j - 1] == '[' && s[j] == '[') {
      for (long long int i = 0; i < id1 + 1; ++i) {
        d[i] += " ";
      }
      d[id1 + 1] += "+-";
      for (long long int i = id1 + 2; i < id2 - 1; ++i) {
        d[i] += "|";
      }
      d[id2 - 1] += "+-";
      for (long long int i = id2; i < mx + 2; ++i) {
        d[i] += " ";
      }
      id1++;
      id2--;
    } else if (s[j - 1] == '[' && s[j] == ']') {
      for (long long int i = 0; i < id1; ++i) {
        d[i] += "  ";
      }
      d[id1] += " -+";
      for (long long int i = id1 + 1; i < id2; ++i) {
        d[i] += "   |";
      }
      d[id2] += " -+";
      for (long long int i = id2 + 1; i < mx + 2; ++i) {
        d[i] += "  ";
      }
    } else if (s[j - 1] == ']' && s[j] == '[') {
      for (long long int i = 0; i < id1; ++i) {
        d[i] += "   ";
      }
      d[id1] += "+-";
      for (long long int i = id1 + 1; i < id2; ++i) {
        d[i] += '|';
      }
      d[id2] += "+-";
      for (long long int i = id2 + 1; i < mx + 2; ++i) {
        d[i] += "   ";
      }
    } else {
      for (long long int i = 0; i < id1 - 1; ++i) {
        d[i] += " ";
      }
      d[id1 - 1] += "-+";
      for (long long int i = id1; i < id2 + 1; ++i) {
        d[i] += "|";
      }
      d[id2 + 1] += "-+";
      for (long long int i = id2 + 2; i < mx + 2; ++i) {
        d[i] += " ";
      }
      id1--;
      id2++;
    }
  }
  for (long long int i = 0; i < mx + 2; ++i) {
    cout << d[i];
    cout << "\n";
  }
  return 0;
}
