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 {


    public void solve() throws IOException {
        int n = nextInt();
        String s = nextToken();
        char res[][];
        int[] ar1 = new int[n];
        for (int i = 0; i < n; i++) {
            if (s.charAt(i) == '[') ar1[i] = 1;
            else ar1[i] = -1;
        }
        int k = 0;
        int b = 0;
        int max = 0;
        int p = 0;
        int prev = 0;
        while (k < n) {
            int c = ar1[k];
            if (prev == 1 && c == -1) {
                p++;
            }
            b += c;
            if (b > max) max = b;
            k++;
            prev = c;
        }
        res = new char[(max - 1) * 2 + 3][n + p * 3];
        for (int i = 0; i < res.length; i++) {
            for (int j = 0; j < res[i].length; j++) {
                res[i][j] = ' ';
            }
        }
        k = 0;
        b = max;
        prev = 0;
        int z = 0;
        while (k < n) {
            int c = ar1[k];
            if (prev == 0) {
                res[0][0] = '+';
                for (int i = 1; i < res.length - 1; i++) {
                    res[i][0] = '|';
                }
                res[res.length - 1][0] = '+';
                z++;
            } else if (prev == 1 && c == 1) {
                b--;
                res[max - b - 1][z] = '-';
                res[max - b][z] = '+';
                for (int i = max - b + 1; i < max - b + 1 + (b - 1) * 2 + 1; i++) {
                    res[i][z] = '|';
                }
                res[max - b + (b - 1) * 2 + 2][z] = '+';
                res[max - b + (b - 1) * 2 + 3][z] = '-';
                z++;
            } else if (prev == 1 && c == -1) {
                res[max - b][z] = '-';
                res[max - b + (b - 1) * 2 + 2][z] = '-';
                z += 2;
                res[max - b][z] = '-';
                res[max - b + (b - 1) * 2 + 2][z] = '-';
                z++;
                res[max - b][z] = '+';
                for (int i = max - b + 1; i < max - b + 1 + (b - 1) * 2 + 1; i++) {
                    res[i][z] = '|';
                }
                res[max - b + (b - 1) * 2 + 2][z] = '+';
                z++;
            } else if (prev == -1 && c == -1) {
                b++;
                res[max - b][z] = '+';
                res[max - b][z - 1] = '-';
                for (int i = max - b + 1; i < max - b + 1 + (b - 1) * 2 + 1; i++) {
                    res[i][z] = '|';
                }
                res[max - b + (b - 1) * 2 + 2][z] = '+';
                res[max - b + (b - 1) * 2 + 2][z - 1] = '-';
                z++;
            } else if (prev == -1 && c == 1) {

                res[max - b][z] = '+';
                for (int i = max - b + 1; i < max - b + 1 + (b - 1) * 2 + 1; i++) {
                    res[i][z] = '|';
                }
                res[max - b + (b - 1) * 2 + 2][z] = '+';
                z++;
            }
            prev = c;
            k++;
        }
        for (int i = 0; i < res.length; i++) {
            for (int j = 0; j < res[i].length; j++) {
                pw.print(res[i][j]);
            }
            pw.println();
        }

    }

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

    BufferedReader br;
    StringTokenizer in;
    PrintWriter pw;

    public String nextToken() throws IOException {
        while (in == null || !in.hasMoreTokens()) {
            in = new StringTokenizer(br.readLine());
        }
        return in.nextToken();
    }

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

    public long nextLong() throws IOException {
        return Long.parseLong(nextToken());
    }

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