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.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Stack;
import java.util.ArrayList;
import java.util.Vector;
import java.util.StringTokenizer;
import java.io.BufferedReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author Chiaki.Hoshinomori
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskD solver = new TaskD();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskD {
        char[] s;
        int[] match;
        int size;
        ArrayList<Integer>[] tree;
        int[] height;
        ArrayList<String> image;

        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n = in.nextInt();
            s = in.next().toCharArray();

            match = new int[n];
            Stack<Integer> stack = new Stack<>();
            for (int i = 0; i < n; i++) {
                if (s[i] == '[') {
                    stack.add(i);
                } else {
                    int j = stack.pop();
                    match[i] = j;
                    match[j] = i;
                }
            }
            size = 0;
            tree = new ArrayList[n];
            height = new int[n];
            int root = build(0, n - 1);
            image = new ArrayList<>();
            for (int i = 0; i < tree[0].size(); ++i) {
                draw(tree[0].get(i), height[0] - 1, false, false);
            }
            int h = image.get(0).length();
            for (int i = 0; i < h; i++) {
                for (String s : image) {
                    out.printf("%c", s.charAt(i));
                }
                out.println();
            }
        }

        private int build(int l, int r) {
            int p = size++;
            height[p] = 1;
            ArrayList<Integer> son = new ArrayList<>();
            if (l > r) son.add(-1);
            for (int i = l; i < r; i = match[i] + 1) {
                int v = build(i + 1, match[i] - 1);
                height[p] = Math.max(height[p], height[v] + 1);
                son.add(v);
            }
            tree[p] = son;
            return p;
        }

        private void draw(int u, int expected, boolean is_first, boolean is_last) {
            int h = height[0] * 2 - 1;
            char[] s = new char[h];
            for (int i = 0; i < h; i++) {
                s[i] = ' ';
            }
            int b = (h - expected * 2 - 1) / 2;
            if (u != -1) {
                s[b] = s[h - b - 1] = '+';
                for (int i = b + 1; i < h - b - 1; ++i) s[i] = '|';
            }
            if (is_first) {
                s[b - 1] = s[h - b] = '-';
            }
            image.add(new String(s));
            if (u != -1) {
                for (int i = 0; i < tree[u].size(); ++i) {
                    draw(tree[u].get(i), expected - 1, i == 0, i == tree[u].size() - 1);
                }
            } else {
                char[] blank = new char[h];
                for (int i = 0; i < h; i++) {
                    blank[i] = ' ';
                }
                image.add(new String(blank));
            }
            for (int i = 0; i < h; i++) {
                s[i] = ' ';
            }
            if (u != -1) {
                s[b] = s[h - b - 1] = '+';
                for (int i = b + 1; i < h - b - 1; ++i) s[i] = '|';
            }
            if (is_last) {
                s[b - 1] = s[h - b] = '-';
            }
            image.add(new String(s));
        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

    }
}