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 main() {
  ios_base::sync_with_stdio(false);
  int k, l, m, n, b[1001] = {0}, c[1001] = {0};
  vector<int> oh, oh1;
  string s;
  vector<vector<char>> OT;
  cin >> n;
  getline(cin, s);
  getline(cin, s);
  for (int i = 0; i < n; i++)
    if (s[i] == '[')
      oh.push_back(i);
    else {
      int ma = 0;
      for (int j = oh[oh.size() - 1] + 1; j < i; j++) ma = max(ma, b[j]);
      b[oh[oh.size() - 1]] = ma + 1;
      b[i] = ma + 1;
      oh.pop_back();
    }
  int M = 0;
  for (int i = 0; i < n; i++) M = max(M, b[i]);
  oh1.push_back(M + 1);
  for (int i = 0; i < n; i++)
    if (s[i] == '[') {
      c[i] = oh1[oh1.size() - 1] - 1;
      oh1.push_back(c[i]);
    } else {
      c[i] = oh1[oh1.size() - 2] - 1;
      oh1.pop_back();
    }
  int dl = 0;
  for (int i = 0; i < n; i++)
    if (b[i] == 1) dl++;
  dl = dl / 2 + dl;
  dl = dl + n;
  OT.assign(M * 2 - 1 + 2, vector<char>(dl, ' '));
  int i = 0, j = 0;
  while (i < n) {
    if (s[i] == '[') {
      int str = (M - c[i]) + 1, sx = 0;
      OT[str - 1][j] = '+';
      OT[str - 1][j + 1] = '-';
      while (sx < c[i] * 2 - 1) {
        OT[str][j] = '|';
        str++;
        sx++;
      }
      OT[str][j] = '+';
      OT[str][j + 1] = '-';
      j++;
      if (b[i] == 1) {
        j++;
        j++;
        j++;
      }
    } else {
      int str = (M - c[i]) + 1, sx = 0;
      OT[str - 1][j] = '+';
      OT[str - 1][j - 1] = '-';
      while (sx < c[i] * 2 - 1) {
        OT[str][j] = '|';
        str++;
        sx++;
      }
      OT[str][j] = '+';
      OT[str][j - 1] = '-';
      j++;
    }
    i++;
  }
  for (i = 0; i < M * 2 - 1 + 2; i++) {
    for (j = 0; j < dl; j++) cout << OT[i][j];
    cout << endl;
  }
  return 0;
}