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.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class MainClass {
    private static FastScanner in = new FastScanner(System.in);
    private static String s;
    private static int[] mas;
    private static int depth;
    private static int[][] paint;
    private static int height = 0;
    private static int length = 0;
    private static int k = 0;
    private static int f = 1;

    public static void main(String args[]) throws IOException {
        int n = in.nextInt();
        mas = new int[n];
        s = in.next();
        getMas(0);
        getSize();
        paint = new int[height][length];
        k = 0;

        depth = 1;
        paintOpen(0);

        for (int i = 1; i < mas.length; i++) {
            if (mas[i-1] == mas[i]){
                k++;
            }
            if (k % 2 == 0){
                paintOpen(f);
            } else if (s.charAt(i) == s.charAt(i-1)){
                paintClose(f);
            } else{
                if(f+3 < length)
                f+=3;
                paintClose(f);
            }
            if(f+1 < length)
                f++;
        }



        for (int i = 0; i < height; i++) {
            for (int j = 0; j < length; j++) {
                if (paint[i][j] == 0) {
                    System.out.print(" ");
                } else System.out.print((char) paint[i][j]);
            }
            if (i < height-1)
                System.out.println();
        }
    }

    static void paintOpen(int j) {
        paint[depth - 1][j] = '+';
        paint[height - depth][j] = '+';
        paint[depth - 1][j + 1] = '-';
        paint[height - depth][j + 1] = '-';
        for (int i = depth; i < height - depth; i++) {
            paint[i][j] = '|';
        }
        depth++;
    }

    static void paintClose(int j) {
        depth--;
        paint[depth - 1][j] = '+';
        paint[height - depth][j] = '+';
        paint[depth - 1][j - 1] = '-';
        paint[height - depth][j - 1] = '-';
        for (int i = depth; i < height - depth; i++) {
            paint[i][j] = '|';
        }
    }

    static void getSize() {
        k = 1;
        for (int i = 0; i < mas.length; i++) {
            if (mas[i] == k) {
                length++;
                k++;
            } else if (mas[i - 1] == k - 1) {
                length += 4;
                k--;
            } else {
                length++;
                k--;
            }
        }
        for (int num :
                mas) {
            if (num > height) height = num;
        }
        height = height * 2 + 1;
    }

    static void getMas(int i) {
        if (s.charAt(i) == '[') {
            mas[i] = ++k;
            //System.out.print(k+" ");
            if (i + 1 < mas.length)
                getMas(i + 1);
        } else if (s.charAt(i) == ']') {
            mas[i] = k--;
            //System.out.print(k+" ");
            //k--;
            if (i + 1 < mas.length)
                getMas(i + 1);
        }
    }
}


class FastScanner {
    private BufferedReader br;
    private StringTokenizer stok;

    FastScanner(InputStream is) {
        br = new BufferedReader(new InputStreamReader(is));
    }

    private String nextToken() throws IOException {
        while (stok == null || !stok.hasMoreTokens()) {
            String s = br.readLine();
            if (s == null) {
                return null;
            }
            stok = new StringTokenizer(s);
        }
        return stok.nextToken();
    }

    int nextInt() throws IOException {
        return Integer.parseInt(nextToken());
    }

    String next() throws IOException {
        return nextToken();
    }
}