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;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;
const int INF = INT_MAX;
const long long INFLL = (long long)1e18;
const double PI = acos(-1.0);
template <class T>
T gcd(T a, T b) {
  return b ? gcd(b, a % b) : a;
}
template <class T>
T lcm(T a, T b) {
  return a / gcd(a, b) * b;
}
template <class T>
T sqr(T a) {
  return a * a;
}
template <class T>
T abs(T a) {
  return (a > 0 ? a : -a);
}
const int N = (int)1e5 + 5;
const int magic = 1 << 18;
const long long prob = LLONG_MAX;
const int dx[] = {1, -1, 0, 0};
const int dy[] = {0, 0, 1, -1};
int n;
string s;
char ans[505][505];
int b[105];
int nxt(int i) {
  int open = 0;
  for (int j = i + 1; j < n; j++) {
    if (s[j] == '[')
      open++;
    else
      open--;
    if (open < 0) return j;
  }
  return -1;
}
void go(int from, int to, int val, int up) {
  b[from] = b[to] = val;
  int F = to + 1;
  while ((F < up && s[F] == ']') || (F < up && b[F] != 0)) {
    F++;
  }
  if (F >= up) return;
  int T = nxt(F);
  go(F, T, val, up);
}
int main() {
  ios::sync_with_stdio(false);
  cout.setf(ios::fixed | ios::showpoint);
  cout.precision(8);
  cin >> n >> s;
  int mx = 0;
  for (int i = 0; i < n; i++) b[i] = 0;
  for (int i = 0; i < n; i++) {
    if (s[i] == ']') continue;
    int to = nxt(i);
    int open = 0;
    for (int j = i + 1; j < to; j++) {
      if (s[j] == '[')
        open++;
      else
        open--;
      mx = max(mx, open + 1);
    }
    mx = max(mx, open + 1);
  }
  int step = mx;
  go(0, nxt(0), step, n);
  step--;
  int from = 0, to = nxt(0);
  while (to < n && from < n) {
    int cur = mx - 1;
    for (int i = from + 1; i < to; i++) {
      if (s[i] == ']' || b[i] > 0) continue;
      go(i, nxt(i), cur, to);
      cur--;
      if (cur == 0) break;
    }
    if (to == n - 1) break;
    from = to + 1;
    to = nxt(from);
  }
  for (int i = 0; i <= 500; i++)
    for (int j = 0; j <= 500; j++) ans[i][j] = ' ';
  int mid = mx;
  int pos = 0, j = 0;
  while (pos < n) {
    ans[mid - b[pos]][j] = '+';
    if (s[pos] == '[')
      ans[mid - b[pos]][j + 1] = '-';
    else
      ans[mid - b[pos]][j - 1] = '-';
    ans[mid + b[pos]][j] = '+';
    if (s[pos] == '[')
      ans[mid + b[pos]][j + 1] = '-';
    else
      ans[mid + b[pos]][j - 1] = '-';
    for (int i = mid; i < mid + b[pos]; i++) ans[i][j] = '|';
    for (int i = mid; i > mid - b[pos]; i--) ans[i][j] = '|';
    if (pos == n - 1) break;
    pos++;
    j++;
    if (s[pos - 1] == '[' && s[pos] == ']') j += 3;
  }
  for (int i = 0; i <= mid + mx; i++) {
    for (int k = 0; k <= j; k++) {
      cout << ans[i][k];
    }
    cout << '\n';
  }
  return 0;
}