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

Solution:
import java.util.Scanner;

public class Problem770D {
    public static int HEIGHT;
    public static int DRAWLEN;
    public static int MAXRANK;
    public static int POSITION = 0;
    public static char[][] drawingField;

    public static void drawOpen(int currentHeight){
        for (int i = MAXRANK-currentHeight; i < HEIGHT-MAXRANK+currentHeight; i++) {
            drawingField[i][POSITION] = '|';
        }
        drawingField[MAXRANK-currentHeight][POSITION]= '+';
        drawingField[HEIGHT-MAXRANK+currentHeight-1][POSITION] = '+';
        drawingField[MAXRANK-currentHeight][POSITION+1]= '-';
        drawingField[HEIGHT-MAXRANK+currentHeight-1][POSITION+1] = '-';
    }

    public static void drawClose(int currentHeight){
        for (int i = MAXRANK-currentHeight; i < HEIGHT-MAXRANK+currentHeight; i++) {
            drawingField[i][POSITION] = '|';
        }
        drawingField[MAXRANK-currentHeight][POSITION]= '+';
        drawingField[HEIGHT-MAXRANK+currentHeight-1][POSITION] = '+';
        drawingField[MAXRANK-currentHeight][POSITION-1]= '-';
        drawingField[HEIGHT-MAXRANK+currentHeight-1][POSITION-1] = '-';
    }

    public static void drawAll(){
        for (int i = 0; i < HEIGHT; i++) {
            for (int j = 0; j < DRAWLEN; j++) {
                System.out.print(drawingField[i][j]);
            }
            System.out.println();
        }
    }

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int length = scanner.nextInt();
        char[] sequence;
        String s = scanner.nextLine();
        s = scanner.nextLine();
        sequence = s.toCharArray();
        int[] ranks = new int[length];
        int maxrank = 0;
        ranks[0]=1;
        for (int i = 1; i < length; i++) {
            if(sequence[i]=='['){
                ranks[i] = ranks[i-1]+1;
            } else {
                ranks[i] = ranks[i-1]-1;
            }
            if (ranks[i]>maxrank) maxrank = ranks[i];
        }
        for (int i = 0; i < length; i++) {
            ranks[i] = maxrank - ranks[i];
            if(sequence[i]=='[')
                ranks[i]++;
        }
        int pairs = 0;
        for (int i = 1; i < length; i++) {
            if((sequence[i]==']')&(sequence[i-1]=='['))
                if(ranks[i]==ranks[i-1]){
                    pairs++;
                }
        }
        DRAWLEN = length + pairs*3;
        if (maxrank>0){
            HEIGHT = maxrank*2+1;
        }
        if(maxrank==0){
            HEIGHT = 3;
        }
        MAXRANK = maxrank;
        drawingField = new char[HEIGHT][DRAWLEN];
        for (int i = 0; i < HEIGHT; i++) {
            for (int j = 0; j < DRAWLEN; j++) {
                drawingField[i][j]=' ';
            }
        }
        int i = 0;
        while(i<length){
            if (sequence[i]=='[') {
                drawOpen(ranks[i]);
                POSITION++;
                i++;
            } else {
                if (sequence[i-1]=='['){
                    POSITION+=3;
                    drawClose(ranks[i]);
                    POSITION++;
                    i++;
                } else {
                    drawClose(ranks[i]);
                    POSITION++;
                    i++;
                }
            }
        }
        drawAll();
    }
}