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>
using namespace std;
int i, j, n, m, k, t, x, y, h, hmax, len, b[909], a[909], beg[909], en[909];
string s, d[1009];
int main() {
  cin >> n >> s;
  len = n;
  s = ' ' + s;
  for (i = 1; i <= len; i++)
    if (s[i] == '[') {
      for (j = i; j <= len; j++) {
        if (s[j] == '[')
          t++;
        else
          t--;
        x = max(x, t);
        if (t == 0) break;
      }
      b[i] = j;
      b[j] = i;
      t = 0;
      if (x > m) {
        m = x;
        k = i;
      }
    }
  for (i = k; i <= b[k]; i++) {
    if (s[i] == '[') {
      a[i] = x;
      x--;
    }
    if (s[i] == ']') {
      x++;
      a[i] = x;
    }
  }
  j = b[k] + 1;
  while (j <= len) {
    if (s[j] == '[') {
      for (i = j; i <= b[j]; i++) {
        if (s[i] == '[') {
          a[i] = x;
          x--;
        }
        if (s[i] == ']') {
          x++;
          a[i] = x;
        }
      }
      j = b[j] + 1;
    } else
      j++;
  }
  j = k - 1;
  while (j >= 1) {
    if (s[j] == ']') {
      for (i = b[j]; i <= j; i++) {
        if (s[i] == '[') {
          a[i] = x;
          x--;
        }
        if (s[i] == ']') {
          x++;
          a[i] = x;
        }
      }
      j = b[j] - 1;
    } else
      j--;
  }
  hmax = 2 * x + 1;
  for (i = 1; i <= len; i++) {
    h = 2 * a[i] + 1;
    beg[i] = ((hmax - h) / 2) + 1;
    en[i] = beg[i] + h - 1;
  }
  t = 0;
  for (i = 1; i <= hmax; i++)
    for (j = 1; j <= len; j++) {
      if (i > beg[j] && i < en[j]) d[i] += '|';
      if (i < beg[j] || i > en[j]) d[i] += ' ';
      if (i == beg[j] || i == en[j]) {
        if (s[j] == '[')
          d[i] += "+-";
        else {
          t -= 2;
          for (; t >= 1; t--) d[i] += ' ';
          d[i] += "-+";
          t = 0;
        }
      }
      if (s[j] == '[' && s[j + 1] == ']') {
        if (beg[j] >= i) t += 3;
        if (i > beg[j] && i < en[j]) d[i] += "   ";
      }
    }
  for (i = 1; i <= hmax / 2 + 1; i++) cout << d[i] << endl;
  for (i = hmax / 2; i >= 1; i--) {
    cout << d[i];
    if (i != 1) cout << endl;
  }
}