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 ProblemsA {
    static final boolean ONLINE_JUDGE = System.getProperty("ONLINE_JUDGE") != null;
 
    public long gcd(long a, long b) {
        if (b == 0)
            return a;
        return gcd(b, a % b);
    }
 
    void cur(int from, int to, int max) {
        for (int j = from; j <= to; j++) {
            if (hights[j] > 0) {
                hights[j] = max;
                hights[sv[j]] = -max;
                cur(j + 1, sv[j] - 1, max - 1);
                j = sv[j];
            }
        }
    }
 
    void solve() throws IOException {
        int n = rI();
        char[] a = rS().toCharArray();
        ArrayDeque<Integer> q = new ArrayDeque<Integer>();
        sv = new int[n];
        for (int i = 0; i < n; i++) {
            if (a[i] == '[') {
                q.add(i);
            } else {
                int c = q.pollLast();
                sv[c] = i;
                sv[i] = c;
            }
        }
 
        hights = new int[n];
        while (chek()) {
            int c = (int) (Math.random() * 100);
            if (c < n) {
                if (c < sv[c]) {
                    makeIn(c, sv[c]);
                }
            }
        }
        int max = (int) maxA(hights);
 
        cur(0, n - 1, max);
 
       
 
        int position = 0;
        int w = n;
        for (int i=1;i<n;i++){
        if(hights[i]<0&&hights[i-1]+hights[i]==0){
        	w+=3;}}
        char [][] ans = new char [w][max*2+1];
        for(int i=0;i<w;++i){
        	for(int j=0;j<max*2+1;++j){
        		ans[i][j]=' ';
        	}
        }
        for (int i = 0; i < n; i++) {
            if (hights[i] > 0) {
                for (int j = max; j > max - hights[i]; j--) {
                    ans[position][j] = '|';
                }
                for (int j = max; j < max + hights[i]; j++) {
                    ans[position][j] = '|';
                }
                ans[position][max - hights[i]] = '+';
                ans[position + 1][max - hights[i]] = '-';
                ans[position][max + hights[i]] = '+';
                ans[position + 1][max + hights[i]] = '-';
            } else {
                if (hights[i] == -hights[i - 1]) {
                    position += 3;
                }
                for (int j = max; j > max + hights[i]; j--) {
                    ans[position][j] = '|';
                }
                for (int j = max; j < max - hights[i]; j++) {
                    ans[position][j] = '|';
                }
                ans[position][max - hights[i]] = '+';
                ans[position - 1][max - hights[i]] = '-';
                ans[position][max + hights[i]] = '+';
                ans[position - 1][max + hights[i]] = '-';
 
            }
            position++;
        }
        for (int j = 0; j < max*2+1; j++) {
            for (int i = 0; i < w; i++) {
 
                out.print(ans[i][j]);
            }
            out.println();
        }
 
    }
 
    boolean chek() {
        for (int i = 0; i < hights.length; i++) {
            if (hights[i] == 0) {
                return true;
            }
        }
        return false;
    }
 
    int[] sv;
    int hights[];
 
    void makeIn(int l, int r) {
        boolean a = false;
        int max = 0;
        for (int i = l + 1; i < r - 1; i++) {
            if (hights[i] == 0) {
                a = true;
                break;
            } else {
                max = maxInt(max, hights[i]);
            }
        }
        if (!a) {
            hights[l] = max + 1;
            hights[r] = -max - 1;
        }
    }
 
    // ===========================================================================
    long minLong(long... values) {
        long min = Integer.MAX_VALUE;
        for (long value : values) {
            min = Math.min(min, value);
        }
        return min;
    }
 
    long maxLong(long... values) {
        long max = Integer.MIN_VALUE;
        for (long value : values) {
            max = Math.max(max, value);
        }
        return max;
    }
 
    int maxInt(int... values) {
        int max = Integer.MIN_VALUE;
        for (int value : values) {
            max = Math.max(max, value);
        }
        return max;
    }
 
    int minInt(int... values) {
        int min = Integer.MAX_VALUE;
        for (int value : values) {
            min = Math.min(min, value);
        }
        return min;
    }
 
    // ==============================================================================
 
    public static void main(String[] args) {
        new ProblemsA().run();
    }
 
    BufferedReader in;
    PrintWriter out;
    StringTokenizer tok;
 
    long maxA(int[] ans) {
        long max = Integer.MIN_VALUE;
        for (int i = 0; i < ans.length; i++) {
            if (ans[i] > max) {
                max = ans[i];
 
            }
        }
        return max;
    }
 
    long minA(long[] a) {
        long min = Long.MAX_VALUE;
        for (int i = 0; i < a.length; i++) {
            if (a[i] < min) {
                min = a[i];
            }
        }
        return min;
    }
 
    void init() throws FileNotFoundException {
 
        if (ONLINE_JUDGE) {
            in = new BufferedReader(new InputStreamReader(System.in));
            out = new PrintWriter(System.out);
        } else {
            in = new BufferedReader(new FileReader("input.txt"));
            out = new PrintWriter("output.txt");
        }
 
        tok = new StringTokenizer("");
    }
 
    void run() {
        try {
            long timeStart = System.currentTimeMillis();
 
            init();
            solve();
 
            out.close();
 
            long timeEnd = System.currentTimeMillis();
            System.err.println("Time = " + (timeEnd - timeStart) + " COMPILED");
        } catch (Exception e) {
            e.printStackTrace();
            System.exit(-1);
        }
    }
 
    long memoryTotal, memoryFree;
 
    void memory() {
        memoryFree = Runtime.getRuntime().freeMemory();
        System.err.println("Memory = " + ((-memoryTotal + memoryFree) >> 10) + " KB");
    }
 
    String readLine() throws IOException {
        return in.readLine();
    }
 
    String delimiter = " ";
 
    String rS() throws IOException {
        while (!tok.hasMoreTokens()) {
            String nextLine = readLine();
            if (null == nextLine)
                return null;
 
            tok = new StringTokenizer(nextLine);
        }
 
        return tok.nextToken(delimiter);
    }
 
    int[] rA(int b) {
        int a[] = new int[b];
        for (int i = 0; i < b; i++) {
            try {
                a[i] = rI();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
        return a;
    }
 
    int rI() throws IOException {
        return Integer.parseInt(rS());
    }
 
    long rL() throws IOException {
        return Long.parseLong(rS());
    }
 
    void sort(int[] a) {
        Integer arr[] = new Integer[a.length];
        for (int i = 0; i < a.length; i++) {
            arr[i] = a[i];
        }
        Arrays.sort(arr);
        for (int i = 0; i < a.length; i++) {
            a[i] = arr[i];
        }
    }
 
}