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


public class Main {
    static char ans[][];
    static int mid;
    public static void main(String args[]) throws IOException {
        Inreader in = new Inreader();
        OutWriter out = new OutWriter();
       int n=in.nextInt();
       boolean isOpening []=new boolean[n];
       String line=in.next();
       char abc[]=line.toCharArray();
       for(int i=0;i<n;i++){
           if(abc[i]=='['){
               isOpening[i]=true;
           }
           else {
               isOpening[i]=false;
           }

       }
       int rang[]=new int[n];
        Stack<Integer> pair=new Stack<>();
        int curr=0;
        for(int i=0;i<n;i++){
            if(isOpening[i]){
                rang[i]=curr;
                curr++;
                pair.add(i);

            }
            else{
                curr--;
                rang[i]=curr;
                pair.pop();

            }
        }
        int spaces=0;
        for(int i=0;i<n-1;i++){
            if(isOpening[i] && !isOpening[i+1]){
                spaces+=3;
            }
        }
        int max=0;
        for(int i=0;i<n;i++){
            if(rang[i]>max){
                max=rang[i];
            }

        }
        for(int i=0;i<n;i++){
            rang[i]=max-rang[i];
        }
        ans=new char[3+2*max][n+spaces];
        for(int i=0;i<3+2*max;i++){
            for(int j=0;j<n+spaces;j++){
                ans[i][j]=' ';
            }

        }
        mid=(3+2*max)/2;
        int k=0;
        for (int i=0;i<n-1;i++){
            create(i+k,isOpening[i],rang[i]);
            if(isOpening[i] && !isOpening[i+1]){
                k+=3;
            }
        }
        create(n-1+k,isOpening[n-1],rang[n-1]);
        for(int i=0;i<3+2*max;i++){
            for(int j=0;j<n+spaces;j++){
                out.print(ans[i][j]);
            }
            out.println();
        }




        out.close();
    }
    static void create(int number,boolean isopening, int height){
        ans[mid][number]='|';
        for(int i=0;i<height;i++){
            ans[i+mid+1][number]='|';
            ans[mid-i-1][number]='|';
        }
        if(isopening){
            ans[mid+height+1][number]='+';
            ans[mid+height+1][number+1]='-';
            ans[mid-height-1][number]='+';
            ans[mid-height-1][number+1]='-';
        }
        else{
            ans[mid+height+1][number]='+';
            ans[mid+height+1][number-1]='-';
            ans[mid-height-1][number]='+';
            ans[mid-height-1][number-1]='-';

        }
    }



    static class Inreader {
        BufferedReader in;

        Inreader(String ProblemName) throws IOException {
            in = new BufferedReader(new FileReader(ProblemName));
        }

        Inreader() throws IOException {
            in = new BufferedReader(new InputStreamReader(System.in));
        }

        StringTokenizer tokenizer = new StringTokenizer("");

        void updateTokenizer() throws IOException {
            if (!tokenizer.hasMoreTokens()) {
                String a = in.readLine();
                if (a != null) {
                    tokenizer = new StringTokenizer(a);
                }
            }
        }

        boolean hasNext() throws IOException {
            updateTokenizer();
            return (tokenizer.hasMoreTokens());
        }

        int nextInt() throws IOException {
            updateTokenizer();

            return Integer.parseInt(tokenizer.nextToken());
        }


        String next() throws IOException {
            updateTokenizer();
            return tokenizer.nextToken();
        }
    }

    static class OutWriter {
        PrintWriter out;

        OutWriter(String Problemname) throws IOException {
            out = new PrintWriter(new FileWriter(Problemname));
        }

        StringBuilder cout = new StringBuilder();

        OutWriter() {
            out = new PrintWriter(System.out);
        }

        public <T> void print(T a) {
            cout.append(a);
        }
        public <T> void println() {
            cout.append('\n');
        }

        void close() {
            out.print(cout.toString());
            out.close();
        }
    }
}