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 PYTHON3):

Solution:
import sys

n = int(input())
s = input()

height = [1] * n
matching = [-1] * n

for i, c in enumerate(s):
    if c == ']':
        height[i] = height[matching[i]]
        continue
    balance = 1
    for j in range(i + 1, n):
        if s[j] == '[':
            balance += 1
        elif s[j] == ']':
            balance -= 1
        height[i] = max(height[i], balance)
        if balance == 0:
            matching[i] = j
            matching[j] = i
            break

max_height = max(height)
cur_height, prev_height = max_height, -1
columns = []

m = 2 * max_height + 1

def draw_bar(pos, height):
    while len(columns) <= pos:
        columns.append([' ' for _ in range(m)])
    upper_plus = max_height - height
    lower_plus = m - upper_plus - 1
    
    columns[pos][upper_plus] = columns[pos][lower_plus] = '+'
    for i in range(upper_plus + 1, lower_plus):
        columns[pos][i] = '|'

def draw_lines(pos, height):
    while len(columns) <= pos:
        columns.append([' ' for _ in range(m)])

    upper_minus = max_height - height
    lower_minus = m - upper_minus - 1

    columns[pos][upper_minus] = columns[pos][lower_minus] = '-'

pos, h = 0, max_height
for i, c in enumerate(s):
    if i > 0:
        if c == ']' and s[i-1] == '[':
            pos += 3
        if c == '[' and s[i-1] == '[':
            h -= 1
        elif c == ']' and s[i-1] == ']':
            h += 1

    draw_bar(pos, h)
    if c == '[':
        draw_lines(pos + 1, h)
    elif c == ']':
        draw_lines(pos - 1, h)

    pos += 1

for i in range(m):
    line = ''.join(column[i] for column in columns).rstrip()
    print(line)