#include <bits/stdc++.h>
#pragma gcc optimize("ofast")
int main(void) {
  size_t size = 0;
  scanf("%ld", &size);
  char fmt[size + 1];
  fmt[size] = '\0';
  scanf("%s", fmt);
  size_t width = 0;
  size_t maxHeight = 1;
  size_t ithX[size];
  size_t depth[size];
  size_t currentDepth = 0;
  char ch = '\0';
  for (size_t ith = 0; ith < size; ith += 1) {
    char thisCh = fmt[ith];
    width += 1;
    if (thisCh == '[') {
      currentDepth += 1;
      depth[ith] = currentDepth;
    } else {
      depth[ith] = currentDepth;
      currentDepth -= 1;
      if (ch == '[') width += 3;
    }
    ithX[ith] = width;
    size_t thisHeight = (currentDepth << 1) + 1;
    if (maxHeight < thisHeight) maxHeight = thisHeight;
    ch = thisCh;
  }
  size_t outLen = width * maxHeight;
  char buffer[outLen + 1];
  buffer[outLen] = '\0';
  memset(buffer, ' ', outLen);
  for (size_t ith = 0; ith < size; ith += 1) {
    size_t x = ithX[ith] - 1;
    size_t d = depth[ith];
    size_t lineEnd = maxHeight - d;
    size_t lineStart = maxHeight - (lineEnd + 1);
    size_t indexStart = x + lineStart * width;
    size_t indexEnd = x + lineEnd * width;
    if (fmt[ith] == '[')
      buffer[indexStart + 1] = buffer[indexEnd + 1] = '-';
    else
      buffer[indexEnd - 1] = buffer[indexStart - 1] = '-';
    buffer[indexStart] = buffer[indexEnd] = '+';
    for (size_t y = lineStart + 1; y < lineEnd; y += 1)
      buffer[x + y * width] = '|';
  }
  for (size_t line = 0; line < maxHeight; line += 1) {
    fwrite(buffer + line * width, sizeof(char), width, stdout);
    puts("");
  }
}
