#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  int r = 1;
  vector<char> a;
  vector<int> b;
  int max = 0;
  for (int i = 0; i < n; i++) {
    char temp;
    cin >> temp;
    a.push_back(temp);
    if (int(temp) == 91) {
      b.push_back(r++);
    } else {
      b.push_back(--r);
    }
    if (i != 0 && b[i] <= b[i - 1]) {
      if (b[i - 1] > max) {
        max = b[i - 1];
      }
    }
  }
  vector<string> ans;
  vector<int> p;
  for (int i = 0; i < n; i++) {
    if (a[i] == '[') {
      if (a[i + 1] == '[') {
        p.push_back(i + 1);
      } else {
        p.push_back(i + 1);
        p.push_back(i + 1);
        p.push_back(0);
      }
    } else {
      if (a[i - 1] == '[') {
        p.push_back(i + 1);
        p.push_back(i + 1);
      } else {
        p.push_back(i + 1);
      }
    }
  }
  bool flag = false;
  for (int i = 0; i < max; i++) {
    string s = "";
    int size = p.size();
    for (int j = 0; j < size; j++) {
      int temp = p[j] - 1;
      if (flag == true) {
        if (s[s.size() - 1] == '+') {
          s += "-";
          flag = false;
          continue;
        } else {
          s += "+";
          flag = false;
          continue;
        }
      }
      if (p[j] == 0) {
        s += " ";
      } else {
        if (a[temp] == '[') {
          if (i + 1 < b[temp]) {
            s += " ";
          } else {
            if (i + 1 > b[temp] && (j == 0 || p[j - 1] != p[j])) {
              s += "|";
            } else if (i + 1 == b[temp]) {
              s += "+";
              flag = true;
            } else {
              s += " ";
            }
          }
        } else {
          if (j != size - 1) {
            if (a[p[j + 1] - 1] == ']' && b[p[j + 1] - 1] == i + 1) {
              s += "-";
              flag = true;
              continue;
            }
          }
          if (i + 1 < b[temp]) {
            s += " ";
          } else {
            if (i + 1 > b[temp] && (j + 1 == size || p[j + 1] != p[j])) {
              s += "|";
            } else if (i + 1 == b[temp]) {
              s += "-";
              flag = true;
            } else {
              s += " ";
            }
          }
        }
      }
    }
    ans.push_back(s);
  }
  string s = "";
  for (int i = 0; i < n; i++) {
    if (a[i] == '[') {
      if (a[i + 1] == '[') {
        s += "|";
      } else if (a[i + 1] == ']') {
        s += "|   ";
      }
    } else {
      s += "|";
    }
  }
  int size = ans.size();
  for (int i = 0; i < size; i++) {
    cout << ans[i] << endl;
  }
  cout << s << endl;
  for (int i = size - 1; i >= 0; i--) {
    cout << ans[i] << endl;
  }
  return 0;
}
