#include <bits/stdc++.h>
using namespace std;
int n;
string quotes = "";
vector<int> level;
int maxDeep = 0;
void input() {
  stack<char> current;
  level.push_back(0);
  quotes = " ";
  char c;
  for (int i = 0; i < n; i++) {
    cin >> c;
    quotes += c;
    switch (c) {
      case '[':
        current.push(c);
        level.push_back(current.size());
        break;
      case ']':
        level.push_back(current.size());
        current.pop();
        break;
    }
    if (current.size() > maxDeep) maxDeep = current.size();
  }
}
int getBottom(int column) {
  return maxDeep + 1 + (maxDeep - level[column] + 1);
}
bool inside(int row, int column) {
  return level[column] < row && row < getBottom(column);
}
bool onEdge(int row, int column) {
  return level[column] == row || row == getBottom(column);
}
bool outside(int row, int column) {
  return level[column] > row || row > getBottom(column);
}
void forOpenQuote(int row, int column) {
  if (onEdge(row, column)) {
    cout << '+' << '-';
  } else if (outside(row, column)) {
    cout << ' ';
  } else if (inside(row, column)) {
    cout << '|';
    if (quotes[column + 1] == '[' && outside(row, column + 1) ||
        quotes[column + 1] == ']')
      cout << ' ';
  }
  if (quotes[column + 1] == ']') cout << ' ';
}
void forCloseQuote(int row, int column) {
  if (onEdge(row, column)) {
    cout << '-' << '+';
  } else if (outside(row, column)) {
    cout << ' ';
  } else if (inside(row, column)) {
    if (!(quotes[column - 1] == ']' &&
          (inside(row, column - 1) || onEdge(row, column - 1))))
      cout << ' ';
    cout << '|';
  }
  if (column != n && quotes[column + 1] == '[' && outside(row, column + 1))
    cout << ' ' << ' ';
}
void general(int row, int column) {
  if (quotes[column] == '[')
    forOpenQuote(row, column);
  else if (quotes[column] == ']')
    forCloseQuote(row, column);
}
void output() {
  int bottomEdge;
  int rowsCount = 2 * maxDeep + 1;
  for (int row = 1; row <= rowsCount; row++) {
    for (int column = 1; column <= n; column++) {
      general(row, column);
    }
    cout << endl;
  }
}
int main() {
  cin >> n;
  input();
  output();
  return 0;
}
