#include <bits/stdc++.h>
using namespace std;
int dp[1000][1000];
int main() {
  stack<int> f;
  string s;
  int ghghgh;
  cin >> ghghgh;
  cin >> s;
  int ma = 0;
  int h = 0, x = 1;
  for (int i = 0; i < s.length(); ++i) {
    if (s[i] == '[')
      dp[x++][h++] = 1;
    else {
      if (s[i - 1] != ']') h += 3;
      ma = max(ma, x - 1);
      dp[--x][h++] = 1;
    }
  }
  int n = s.length();
  for (int i = 0; i < h; ++i) {
    for (int j = 0; j < ma; ++j) {
      if (dp[j + 1][i] == 1) {
        dp[j][i] = 2;
        dp[2 * ma - j][i] = 2;
        for (int k = j + 1; k < 2 * ma - j; ++k) dp[k][i] = 1;
        break;
      }
    }
  }
  int jj = 0;
  for (int i = 0; i <= 2 * ma; ++i)
    for (int j = 0; j < h; ++j)
      if (dp[i][j] == 2)
        if (jj) {
          jj = 0;
          dp[i][j - 1] = 3;
        } else {
          jj = 1;
          dp[i][j + 1] = 3;
        }
  for (int i = 0; i <= 2 * ma; ++i) {
    for (int j = 0; j < h; ++j) {
      if (dp[i][j] == 3) cout << '-';
      if (!dp[i][j]) cout << " ";
      if (dp[i][j] == 1) cout << '|';
      if (dp[i][j] == 2) cout << "+";
    }
    cout << "\n";
  }
}
