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>
const int INF = 2147483647;
using namespace std;
int n, k, x;
vector<int> dp(1024, 0);
string getSimple(const string& s, int pos) {
  string ans;
  int ct = 1;
  ans += s[pos];
  while (ct) {
    pos++;
    ans += s[pos];
    if (s[pos] == '[')
      ct++;
    else
      ct--;
  }
  return ans;
}
vector<int> getHeights(string s) {
  int sz = s.size();
  vector<int> ans(sz, 0);
  bool found = false;
  int pos = 0;
  for (int i = 0; i < sz - 1 && !found; i++) {
    if (s[i] == '[' && s[i + 1] == ']') {
      found = true;
      pos = i;
    }
  }
  ans[pos] = 3, ans[pos + 1] = 3;
  for (int i = pos - 1; i >= 0; i--) {
    if (s[i] == '[' && s[i + 1] == '[')
      ans[i] = ans[i + 1] + 2;
    else if (s[i] == ']' && s[i + 1] == ']')
      ans[i] = ans[i + 1] - 2;
    else
      ans[i] = ans[i + 1];
  }
  for (int i = pos + 2; i < sz; i++) {
    if (s[i] == '[' && s[i - 1] == '[')
      ans[i] = ans[i - 1] - 2;
    else if (s[i] == ']' && s[i - 1] == ']')
      ans[i] = ans[i - 1] + 2;
    else
      ans[i] = ans[i - 1];
  }
  int mn = *min_element(ans.begin(), ans.end());
  for (int& i : ans) {
    i += 3 - mn;
  }
  return ans;
}
void draw(string s, vector<int> heights) {
  int sz = s.size();
  vector<string> ans(heights[0]);
  ans[0] += "+-";
  for (int i = 1; i < heights[0] - 1; i++) {
    ans[i] += '|';
  }
  ans[heights[0] - 1] += "+-";
  for (int i = 1; i < sz; i++) {
    int start = (heights[0] - heights[i]) / 2;
    int end = start + heights[i] - 1;
    if (s[i] == '[' && s[i - 1] == '[') {
      ans[start] += "+-";
      ans[end] += "+-";
      for (int j = start + 1; j < end; j++) {
        ans[j] += '|';
      }
      for (int j = 0; j < start; j++) {
        ans[j] += ' ';
      }
      for (int j = end + 1; j < heights[0]; j++) {
        ans[j] += ' ';
      }
    } else if (s[i] == '[' && s[i - 1] == ']') {
      for (int j = 0; j < start; j++) {
        ans[j] += "   ";
      }
      for (int j = end + 1; j < heights[0]; j++) {
        ans[j] += "   ";
      }
      ans[start] += "+-";
      ans[end] += "+-";
      for (int j = start + 1; j < end; j++) {
        ans[j] += '|';
      }
    } else if (s[i] == ']' && s[i - 1] == ']') {
      ans[start] += "-+";
      ans[end] += "-+";
      for (int j = start + 1; j < end; j++) {
        ans[j] += '|';
      }
      for (int j = 0; j < start; j++) {
        ans[j] += ' ';
      }
      for (int j = end + 1; j < heights[0]; j++) {
        ans[j] += ' ';
      }
    } else if (s[i] == ']' && s[i - 1] == '[') {
      for (int j = 0; j < start; j++) {
        ans[j] += "  ";
      }
      for (int j = end + 1; j < heights[0]; j++) {
        ans[j] += "  ";
      }
      ans[start] += " -+";
      ans[end] += " -+";
      for (int j = start + 1; j < end; j++) {
        ans[j] += "   |";
      }
    }
  }
  for (string s : ans) {
    cout << s << endl;
  }
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int n;
  cin >> n;
  string s;
  cin >> s;
  vector<string> vs;
  int pos = 0;
  while (pos < n - 1) {
    string s2 = getSimple(s, pos);
    vs.push_back(s2);
    pos += s2.size();
  }
  vector<vector<int>> vvi;
  for (auto s : vs) {
    vvi.push_back(getHeights(s));
  }
  int maxHeight = 0;
  for (auto vi : vvi) {
    maxHeight = max(vi[0], maxHeight);
  }
  vector<int> heights;
  for (auto vi : vvi) {
    for (int i : vi) {
      heights.push_back(maxHeight - vi[0] + i);
    }
  }
  draw(s, heights);
  return 0;
}