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;
class item {
 public:
  item();
  void addChild(item* c);
  item* getChild();
  void addNext(item* c);
  item* getParent();
  void delParent();
  void initHeights();
  int getW();
  int getH();
  void print(char** field, int x, int y);

 private:
  int width = 1;
  vector<int>* heights = NULL;
  int stage = 0;
  item* parent = NULL;
  item* child = NULL;
  item* next = NULL;
  item* last = NULL;
};
int main() {
  int n = 0;
  scanf(" %d", &n);
  char str[101];
  scanf("%s", str);
  item* base = new item();
  base->initHeights();
  item* current = base;
  for (int i = 0; i < n; i++) {
    if (str[i] == '[') {
      item* i = new item();
      current->addChild(i);
      current = i;
    } else if (str[i] == ']') {
      current = current->getParent();
    } else {
      throw 1;
    }
  }
  current = base->getChild();
  current->delParent();
  current->print(NULL, 0, 0);
  printf("\n");
}
item::item() {}
void item::addChild(item* c) {
  c->parent = this;
  c->stage = this->stage + 1;
  c->heights = this->heights;
  if (this->heights->size() == this->stage + 1) {
    for (auto it = this->heights->begin(); it != this->heights->end(); ++it) {
      (*it) += 2;
    }
    this->heights->push_back(1);
  }
  if (this->child != NULL) {
    this->child->addNext(c);
    this->child->last = c;
  } else {
    this->child = c;
  }
  auto it = this;
  do {
    it->width += 2;
    it = it->parent;
  } while (it != NULL);
}
item* item::getChild() { return this->child; }
void item::addNext(item* c) {
  c->stage = this->stage;
  if (this->next != NULL) {
    this->last->addNext(c);
    this->last = c;
    return;
  }
  this->next = c;
  this->last = c;
  auto it = this->parent;
  while (it != NULL) {
    it->width += 3;
    it = it->parent;
  }
}
item* item::getParent() { return this->parent; }
void item::delParent() {
  delete this->parent;
  this->parent = NULL;
}
void item::initHeights() {
  this->heights = new vector<int>();
  heights->push_back(1);
}
int item::getW() { return this->width; }
int item::getH() { return (this->heights)->at(this->stage); }
void item::print(char** field, int x, int y) {
  if (field == NULL) {
    int width = 0;
    item* it = this;
    do {
      width += it->getW();
      width += 4;
      it = it->next;
    } while (it != NULL);
    int height = this->getH() + 2;
    field = (char**)calloc(height, sizeof(char*));
    for (int i = 0; i < height; i++) {
      field[i] = (char*)calloc(width + 1, sizeof(char));
    }
    for (int i = 0; i < height; i++) {
      field[i][width] = 0;
    }
    this->print(field, x, y);
    for (int i = 0; i < height; i++) {
      printf("%s\n", field[i]);
    }
    return;
  }
  int w = this->getW();
  int h = this->getH();
  field[x][y] = '+';
  field[x][y + 1] = '-';
  field[x][w + y + 2] = '-';
  field[x][w + y + 3] = '+';
  field[h + x + 1][y] = '+';
  field[h + x + 1][y + 1] = '-';
  field[h + x + 1][w + y + 2] = '-';
  field[h + x + 1][w + y + 3] = '+';
  for (int i = 0; i < w; i++) {
    field[x][y + 2 + i] = ' ';
    field[x + h + 1][y + 2 + i] = ' ';
  }
  for (int i = 0; i < h; i++) {
    field[x + i + 1][y] = '|';
    field[x + i + 1][y + w + 3] = '|';
  }
  if (w == 1) {
    for (int i = 0; i < h; i++) {
      for (int j = 0; j < 3; j++) {
        field[x + i + 1][y + j + 1] = ' ';
      }
    }
  }
  if (this->child != NULL) {
    this->child->print(field, x + 1, y + 1);
  }
  if (this->next != NULL) {
    this->next->print(field, x, y + w + 4);
  }
}