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.*;
import java.util.*;

public class Main {

    private static final int SIZE = 1000;
    private static BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
    private static PrintWriter out = new PrintWriter(System.out, true);
    private static StringTokenizer st;

    public static void main(String[] args) throws Exception {
        int n = nextInt();
        String s = in.readLine().trim();
        char[][] m = new char[SIZE][SIZE];
        for (int i = 0; i < SIZE; i++) {
            Arrays.fill(m[i], ' ');
        }
        int x = 0;
        int y = 0;
        int maxY = 0;
        int maxX = 0;
        int[][] xy = new int[s.length()][2];
        for (int i = 0; i < s.length(); i++) {
            xy[i][0] = x;
            xy[i][1] = y;
            maxY = Math.max(maxY, y);
            maxX = Math.max(maxX, x);
            if (s.charAt(i) == '[') {
                m[y][x] = '+';
                m[y][x + 1] = '-';
                if (i + 1 < s.length()) {
                    char next = s.charAt(i + 1);
                    if (next == '[') {
                        x++;
                        y++;
                    }
                    if (next == ']') {
                        x += 4;
                    }
                }
            } else {
                m[y][x] = '+';
                m[y][x - 1] = '-';
                if (i + 1 < s.length()) {
                    char next = s.charAt(i + 1);
                    if (next == '[') {
                        x++;
                    }
                    if (next == ']') {
                        x++;
                        y--;
                    }
                }
            }
        }
        int height = 0;
        for (int i = 0; i < s.length(); i++) {
            int cx = xy[i][0];
            int cy = xy[i][1];
            int dist = maxY - cy;
            for (int j = 1; j <= dist; j++) {
                m[cy + j][cx] = '|';
            }
            m[maxY + 1][cx] = '|';
            for (int j = 1; j <= dist; j++) {
                m[maxY + 1 + j][cx] = '|';
            }
            m[maxY + dist + 2][cx] = '+';
            if (s.charAt(i) == '[') {
                m[maxY + dist + 2][cx + 1] = '-';
            } else {
                m[maxY + dist + 2][cx - 1] = '-';
            }
            height = Math.max(height, maxY + dist + 2);
        }
        for (int i = 0; i <= height; i++) {
            for (int j = 0; j <= maxX; j++) {
                out.print(m[i][j]);
            }
            out.println();
        }
    }

    private static void drawOpen(char[][] m, int x, int y) {
        m[y][x] = '+';
        m[y][x + 1] = '-';
        for (int i = y + 1; i <= SIZE - y - 1; i++) {
            m[i][x] = '|';
        }
        m[SIZE - y - 1][x] = '+';
        m[SIZE - y - 1][x + 1] = '-';
    }

    private static void drawClosed(char[][] m, int x, int y) {
        m[y][x] = '+';
        m[y][x - 1] = '-';
        for (int i = y + 1; i <= SIZE - y - 1; i++) {
            m[i][x] = '|';
        }
        m[SIZE - y - 1][x] = '+';
        m[SIZE - y - 1][x - 1] = '-';
    }

    private static int nextInt() throws Exception {
        if (st == null || !st.hasMoreTokens()) st = new StringTokenizer(in.readLine());
        return Integer.parseInt(st.nextToken());
    }

    private static long nextLong() throws Exception {
        if (st == null || !st.hasMoreTokens()) st = new StringTokenizer(in.readLine());
        return Long.parseLong(st.nextToken());
    }

    private static double nextDouble() throws Exception {
        if (st == null || !st.hasMoreTokens()) st = new StringTokenizer(in.readLine());
        return Double.parseDouble(st.nextToken());
    }

    private static String nextToken() throws Exception {
        if (st == null || !st.hasMoreTokens()) st = new StringTokenizer(in.readLine());
        return st.nextToken();
    }

}