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;
struct Node1 {
  char info;
  int index;
};
struct Node {
  char info;
  Node *next;
};
struct Stack {
  Node *head;
  int st_size;
  void push(char x);
  char pop();
  void clear();
  bool is_empty();
  ~Stack();
  Stack();
};
Stack::~Stack() { this->clear(); }
Stack::Stack() {
  this->head = NULL;
  this->st_size = 0;
}
bool Stack::is_empty() { return this->head == NULL; }
void Stack::push(char x) {
  Node *n = new Node;
  n->info = x;
  n->next = this->head;
  this->head = n;
  ++this->st_size;
}
char Stack::pop() {
  Node *k = this->head->next;
  char info = this->head->info;
  delete this->head;
  this->head = k;
  --this->st_size;
  return info;
}
void Stack::clear() {
  while (!this->is_empty()) {
    this->pop();
  }
}
int main() {
  Stack *br = new Stack;
  int n;
  int max_size = 0;
  cin >> n;
  char *s = new char[n];
  Node1 *f = new Node1[n];
  for (int i = 0; i < n; ++i) {
    cin >> s[i];
  }
  for (int size = 0, i = 0; s[i] != 0 && !(br->is_empty() && s[i] == ']');
       ++i) {
    if (s[i] == '[') {
      br->push(s[i]);
      f[i].info = s[i];
      ++size;
      f[i].index = size;
    }
    if (!br->is_empty() && (s[i] == ']' && br->head->info == '[')) {
      if (size > max_size) {
        max_size = size;
      }
      f[i].info = s[i];
      f[i].index = size;
      --size;
      br->pop();
    }
  }
  int h = 1 + 2 * max_size;
  char **l = new char *[h];
  for (int i = 0; i < h; ++i) {
    l[i] = new char[10 * n];
  }
  for (int k = 0, j = 0; k < n;) {
    if (f[k].info == '[') {
      l[f[k].index - 1][j] = '+';
      for (int i = j + 2; i < 10 * n; ++i) {
        l[f[k].index - 1][i] = ' ';
        l[h - f[k].index][i] = ' ';
      }
      for (int q = f[k].index; q < h - f[k].index; ++q) {
        l[q][j] = '|';
        if (f[k + 1].info == ']') {
          l[q][j + 1] = ' ';
          l[q][j + 2] = ' ';
          l[q][j + 3] = ' ';
        }
      }
      l[h - f[k].index][j] = '+';
      l[h - f[k].index][j + 1] = '-';
      l[f[k].index - 1][j + 1] = '-';
      ++k;
      j += 1;
    }
    if (f[k].info == ']') {
      if (f[k - 1].info == '[') {
        j += 3;
      }
      l[f[k].index - 1][j] = '+';
      for (int q = f[k].index; q < h - f[k].index; ++q) {
        l[q][j] = '|';
      }
      l[h - f[k].index][j] = '+';
      l[h - f[k].index][j - 1] = '-';
      l[f[k].index - 1][j - 1] = '-';
      if (f[k].index == 1) {
        for (int i = 0; i < h; ++i) {
          l[i][j + 1] = '\0';
        }
      }
      ++k;
      ++j;
    }
  }
  for (int i = 0; i < h; ++i) {
    for (int j = 0; l[i][j] != 0; ++j) {
      cout << l[i][j];
    }
    cout << endl;
  }
  delete br;
  delete[] s;
  delete[] f;
  for (int m = 0; m < h; ++m) {
    delete[] l[m];
  }
  delete[] l;
  return 0;
}