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

public class Main {
    public void solve() throws IOException {
        int n = nextInt();
        String s = nextToken();
        int max = -1;
        int t = 0;
        for (int i = 0; i < n; i++) {
            if (s.charAt(i) == '[') {
                t++;
            } else {
                t--;
            }
            if (t > max) {
                max = t;
            }
        }
        int[] w = new int[n];
        for (int i = 0; i < n; i++) {
            if (s.charAt(i) == ']') {
                if (s.charAt(i) != s.charAt(i - 1)) {
                    w[i] = w[i - 1];
                } else {
                    w[i] = w[i - 1] + 1;
                }
                t--;
            } else {
                w[i] = max - t;
                t++;
            }
        }
        int l = 0;
        for (int i = 0; i < n; i++) {
            if (s.charAt(i) == '[' && s.charAt(i + 1) == ']') {
                l += 5;
            } else {
                if (s.charAt(i) == '[') {
                    l++;
                } else {
                    if (s.charAt(i) == ']' && s.charAt(i - 1) != '[') {
                        l++;
                    }
                }
            }
        }
        char[][] q = new char[max * 2 + 1][l];
        for (int i = 0; i < 2 * max + 1; i++) {
            for (int j = 0; j < l; j++) {
                q[i][j] = ' ';
            }
        }
        int l1 = 0;
        for (int i = 0; i < n; i++) {
            if (s.charAt(i) == '[' && s.charAt(i + 1) == ']') {
                for (int j = 0; j < w[i]; j++) {
                    q[max + j][l1] = '|';
                    q[max - j][l1] = '|';
                    q[max + j][l1 + 4] = '|';
                    q[max - j][l1 + 4] = '|';
                }
                q[max + w[i]][l1] = '+';
                q[max - w[i]][l1] = '+';
                q[max + w[i]][l1 + 1] = '-';
                q[max - w[i]][l1 + 1] = '-';
                q[max + w[i]][l1 + 4] = '+';
                q[max - w[i]][l1 + 4] = '+';
                q[max + w[i]][l1 + 3] = '-';
                q[max - w[i]][l1 + 3] = '-';
                l1 += 5;
            } else {
                if (s.charAt(i) == '[') {
                    for (int j = 0; j < w[i]; j++) {
                        q[max + j][l1] = '|';
                        q[max - j][l1] = '|';
                    }
                    q[max + w[i]][l1] = '+';
                    q[max - w[i]][l1] = '+';
                    q[max + w[i]][l1 + 1] = '-';
                    q[max - w[i]][l1 + 1] = '-';
                    l1++;
                } else {
                    if (s.charAt(i) == ']' && s.charAt(i - 1) == ']') {
                        for (int j = 0; j < w[i]; j++) {
                            q[max + j][l1] = '|';
                            q[max - j][l1] = '|';
                        }
                        q[max + w[i]][l1] = '+';
                        q[max - w[i]][l1] = '+';
                        q[max + w[i]][l1 - 1] = '-';
                        q[max - w[i]][l1 - 1] = '-';
                        l1++;
                    }
                }
            }
        }
        for(int i = 0; i < 2 * max + 1; i++){
            for(int j = 0; j < l; j++){
                out.print(q[i][j]);
            }
            out.println();
        }
    }

    BufferedReader br;
    StringTokenizer sc;
    PrintWriter out;

    public String nextToken() throws IOException {
        while (sc == null || !sc.hasMoreTokens()) {
            try {
                sc = new StringTokenizer(br.readLine());
            } catch (Exception e) {
                return null;
            }
        }
        return sc.nextToken();
    }

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

    public static void main(String[] args) throws IOException {
        try {
            Locale.setDefault(Locale.US);
        } catch (Exception e) {
        }
        new Main().run();
    }

    public void run() {
        try {
            br = new BufferedReader(new InputStreamReader(System.in));
            out = new PrintWriter(System.out);
            solve();
            out.close();
        } catch (Exception e) {
            e.printStackTrace();
            System.exit(1);
        }
    }
}