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;

/**
 * Created by Roman Fedorov on 11.03.2017.
 */
public class DrawBrackets {
    private static int maxValue(int[] vals) {
        int maxVal = Integer.MIN_VALUE;
        for (int i = 0; i < vals.length; i++) {
            maxVal = Math.max(maxVal, vals[i]);
        }
        return maxVal;
    }

    private static int getWidth(String s) {
        int spaces = 0;
        for (int i = 1; i < s.length(); i++) {
            if ((s.charAt(i - 1) == '[') && (s.charAt(i) == ']')) {
                spaces++;
            }
        }
        return s.length() + spaces * 3;
    }

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int len = scanner.nextInt();
        scanner.nextLine();
        String s = scanner.nextLine();
        int[] depth = new int[len];
        int currentDepth = 0;
        for (int i = 0; i < len; i++) {
            if (s.charAt(i) == '[') {
                depth[i] = currentDepth++;
            } else {
                depth[i] = --currentDepth;
            }
        }
        int maxDepth = maxValue(depth);
        int height = 3 + 2 * maxDepth;
        int width = getWidth(s);

        String formattedBrackets = addSpaces(s, width);
        int[] formattedDepth = getFormattedDepth(formattedBrackets);
        char[][] picture = new char[height][width];
        for (int r = 0; r < height; r++) {
            for (int c = 0; c < width; c++) {
                picture[r][c] = ' ';
            }
        }

        for (int col = 0; col < width; col++) {
            if (formattedBrackets.charAt(col) != ' ') {
                picture[formattedDepth[col]][col] = '+';
                for (int row = formattedDepth[col] + 1; row < height - formattedDepth[col] - 1; row++) {
                    picture[row][col] = '|';
                }
                picture[height - formattedDepth[col] - 1][col] = '+';
                if (formattedBrackets.charAt(col) == '[') {
                    picture[formattedDepth[col]][col + 1] = '-';
                    picture[height - formattedDepth[col] - 1][col + 1] = '-';
                } else if (formattedBrackets.charAt(col) == ']') {
                    picture[formattedDepth[col]][col - 1] = '-';
                    picture[height - formattedDepth[col] - 1][col - 1] = '-';
                }
            }
        }

        for (int r = 0; r < height; r++) {
            for (int c = 0; c < width; c++) {
                System.out.print(picture[r][c]);
            }
            System.out.println();
        }
    }

    private static int[] getFormattedDepth(String s) {
        int[] depth = new int[s.length()];
        int currentDepth = 0;
        for (int i = 0; i < s.length(); i++) {
            if (s.charAt(i) == '[') {
                depth[i] = currentDepth++;
            } else if (s.charAt(i) == ']') {
                depth[i] = --currentDepth;
            }
        }
        return depth;
    }

    private static String addSpaces(String s, int width) {
        char[] res = new char[width];
        int resPointer = 0;
        for (int i = 1; i < s.length(); i++) {
            res[resPointer++] = s.charAt(i - 1);
            if ((s.charAt(i - 1) == '[') && (s.charAt(i) == ']')) {
                res[resPointer++] = ' ';
                res[resPointer++] = ' ';
                res[resPointer++] = ' ';
            }
        }
        res[resPointer] = s.charAt(s.length() - 1);
        return new String(res);
    }
}