Problem: A sequence of square brackets is regular if by inserting symbols "+" and "1" into it, you can get a regular mathematical expression from it. For example, sequences "[[]][]", "[]" and "[[][[]]]" — are regular, at the same time "][", "[[]" and "[[]]][" — are irregular. 

Draw the given sequence using a minimalistic pseudographics in the strip of the lowest possible height — use symbols '+', '-' and '|'. For example, the sequence "[[][]][]" should be represented as: 
    
    
      
    +-        -++- -+      
    |+- -++- -+||   |  
    ||   ||   |||   |  
    |+- -++- -+||   |  
    +-        -++- -+  
    

Each bracket should be represented with the hepl of one or more symbols '|' (the vertical part) and symbols '+' and '-' as on the example which is given above.

Brackets should be drawn without spaces one by one, only dividing pairs of consecutive pairwise brackets with a single-space bar (so that the two brackets do not visually merge into one symbol). The image should have the minimum possible height. 

The enclosed bracket is always smaller than the surrounding bracket, but each bracket separately strives to maximize the height of the image. So the pair of final brackets in the example above occupies the entire height of the image.

Study carefully the examples below, they adequately explain the condition of the problem. Pay attention that in this problem the answer (the image) is unique. 

Input

The first line contains an even integer n (2 ≤ n ≤ 100) — the length of the sequence of brackets.

The second line contains the sequence of brackets — these are n symbols "[" and "]". It is guaranteed that the given sequence of brackets is regular. 

Output

Print the drawn bracket sequence in the format which is given in the condition. Don't print extra (unnecessary) spaces. 

Examples

Input

8
[[][]][]


Output

+-        -++- -+
|+- -++- -+||   |
||   ||   |||   |
|+- -++- -+||   |
+-        -++- -+


Input

6
[[[]]]


Output

+-     -+
|+-   -+|
||+- -+||
|||   |||
||+- -+||
|+-   -+|
+-     -+


Input

6
[[][]]


Output

+-        -+
|+- -++- -+|
||   ||   ||
|+- -++- -+|
+-        -+


Input

2
[]


Output

+- -+
|   |
+- -+


Input

4
[][]


Output

+- -++- -+
|   ||   |
+- -++- -+

Solution (in CPP):

Solution:
#include <bits/stdc++.h>
int abs(int a) { return a < 0 ? -a : a; }
char b[260][260];
int main() {
  int i, j, n, maxd = 1, depth[100], fl = 0, col;
  char c;
  scanf("%i\n%c", &n, &c);
  depth[0] = 1;
  for (i = 1; i < n; ++i) {
    scanf("%c", &c);
    if (c == '[') {
      depth[i] = abs(depth[i - 1] + 1);
    } else {
      depth[i] = -abs(depth[i - 1]);
    }
    if (depth[i - 1] < 0) ++depth[i];
    if (depth[i] > maxd) maxd = depth[i];
  }
  b[0][0] = '+';
  for (i = 1; i < maxd * 2; ++i) b[i][0] = '|';
  b[maxd * 2][0] = '+';
  col = 1;
  for (j = 1; j < (n - 1); ++j, ++col) {
    for (i = 0; i < abs(depth[j]) - 2; ++i) b[i][col] = ' ';
    if (depth[j] > 0) {
      if (depth[j - 1] > 0) {
        b[abs(depth[j]) - 2][col] = '-';
        fl = 1;
      } else
        b[abs(depth[j]) - 2][col] = ' ';
    } else {
      if (depth[j - 1] > 0) {
        b[abs(depth[j]) - 2][col] = ' ';
        b[abs(depth[j]) - 1][col] = '-';
        for (i = abs(depth[j]); i < (maxd * 2 - abs(depth[j]) + 1); ++i)
          b[i][col] = ' ';
        b[i][col] = '-';
        ++i;
        for (; i <= maxd * 2; ++i) b[i][col] = ' ';
        ++col;
        for (i = 0; i <= maxd * 2; ++i) b[i][col] = ' ';
        ++col;
        for (i = 0; i < abs(depth[j]) - 1; ++i) b[i][col] = ' ';
        b[abs(depth[j]) - 1][col] = '-';
        for (i = abs(depth[j]); i < (maxd * 2 - abs(depth[j]) + 1); ++i)
          b[i][col] = ' ';
        b[i][col] = '-';
        ++i;
        for (; i <= maxd * 2; ++i) b[i][col] = ' ';
        ++col;
        for (i = 0; i < abs(depth[j]) - 2; ++i) b[i][col] = ' ';
      }
      if (depth[j + 1] < 0) {
        b[abs(depth[j]) - 2][col] = '-';
        fl = 1;
      } else
        b[abs(depth[j]) - 2][col] = ' ';
    }
    b[abs(depth[j]) - 1][col] = '+';
    for (i = abs(depth[j]); i < (maxd * 2 - abs(depth[j]) + 1); ++i)
      b[i][col] = '|';
    b[i][col] = '+';
    if (fl) {
      ++i;
      b[i][col] = '-';
      fl = 0;
    }
    ++i;
    for (; i <= maxd * 2; ++i) b[i][col] = ' ';
  }
  if (depth[n - 2] > 0) {
    b[abs(depth[n - 1]) - 2][col] = ' ';
    b[abs(depth[n - 1]) - 1][col] = '-';
    for (i = abs(depth[n - 1]); i < (maxd * 2 - abs(depth[n - 1]) + 1); ++i)
      b[i][col] = ' ';
    b[i][col] = '-';
    ++i;
    for (; i <= maxd * 2; ++i) b[i][col] = ' ';
    ++col;
    for (i = 0; i <= maxd * 2; ++i) b[i][col] = ' ';
    ++col;
    for (i = 0; i < abs(depth[n - 1]) - 1; ++i) b[i][col] = ' ';
    b[abs(depth[n - 1]) - 1][col] = '-';
    for (i = abs(depth[n - 1]); i < (maxd * 2 - abs(depth[n - 1]) + 1); ++i)
      b[i][col] = ' ';
    b[i][col] = '-';
    ++i;
    for (; i <= maxd * 2; ++i) b[i][col] = ' ';
    ++col;
    for (i = 0; i < abs(depth[n - 1]) - 2; ++i) b[i][col] = ' ';
  }
  b[0][col] = '+';
  for (i = 1; i < maxd * 2; ++i) b[i][col] = '|';
  b[maxd * 2][col] = '+';
  ++col;
  for (i = 0; i <= maxd * 2; ++i) b[i][col] = 0;
  for (i = 0; i <= maxd * 2; ++i) printf("%s\n", b[i]);
  return 0;
}