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.PrintStream;
import java.util.ArrayList;
import java.util.Scanner;
import java.util.Stack;

public class C {

	public static PrintStream out = System.out;
	public static Scanner in = new Scanner(System.in);

	public static void main(String[] args) {
		class el {
			private int depth, dir, pos;

			public el(int pos, int depth, int dir) {
				this.setPos(pos);
				this.setDepth(depth);
				this.setDir(dir);
			}

			public int getDepth() {
				return depth;
			}

			public void setDepth(int depth) {
				this.depth = depth;
			}

			public int getDir() {
				return dir;
			}

			public void setDir(int dir) {
				this.dir = dir;
			}

			public int getPos() {
				return pos;
			}

			public void setPos(int pos) {
				this.pos = pos;
			}

		}

		int n = in.nextInt(), depth = 0, mid = 0;
		String s = in.next();
		Stack<el> q = new Stack<>();
		ArrayList<el> res = new ArrayList<el>();
		for (int i = 0; i < s.length(); i++) {
			String s1 = "";
			s1 += s.charAt(i);
			if (s1.equals("["))
				res.add(new el(i, 0, 1));
			else
				res.add(new el(i, 0, -1));

		}
		for (int i = 0; i < s.length(); i++) {
			String s1 = "";
			s1 += s.charAt(i);
			if (s1.equals("["))
				q.push(res.get(i));
			else {
				el xr = new el(q.peek().getPos(), q.peek().getDepth(), q.peek().getDir());
				el xl = new el(res.get(i).getPos(), res.get(i).getDepth(), res.get(i).getDir());
				q.pop();
				xr.setDepth(2 * (q.size() + 1) + 1);
				xl.setDepth(2 * (q.size() + 1) + 1);
				res.set(xr.pos, xr);
				res.set(xl.pos, xl);
				if (xr.getDepth() > depth)
					depth = xr.getDepth();
			}

		}
		mid = depth / 2 + 1;
		if (depth != 3)
			for (int i = 0; i < res.size(); i++) {
				res.get(i).setDepth((depth + 3) / 2 + ((depth + 3) / 2 - res.get(i).getDepth()));
			}
		for (int i = 0; i < depth; i++) {
			boolean oka = true,okb=true;
			for (int j = 0; j < res.size(); j++) {
				if (res.get(j).getDir() == 1) {
					if (res.get(j + 1).getDir() == -1) {
						oka = false;
					} else
						oka = true;
					if (res.get(j).getDepth() == 2 * (Math.abs(mid - i - 1)) + 1) {
						out.print("+-");
						if(!oka)
						out.print(" ");
					} else if (res.get(j).getDepth() > 2 * (Math.abs(mid - i - 1)) + 1) {
						out.print("|");
						if (!oka)
							out.print("   ");
					} else
					{	if(!oka)
						out.print(" ");
						out.print(" ");
					}
				} else {
					if(j<res.size()-1)
						if (res.get(j + 1).getDir() == 1) {
							okb = false;
						} else
							okb = true;
					if (res.get(j).getDepth() == 2 * (Math.abs(mid - i - 1)) + 1){
						out.print("-+");
					}
					else if (res.get(j).getDepth() > 2 * (Math.abs(mid - i - 1)) + 1)
						out.print("|");
					else{
						if(!okb)
							out.print("  ");
						out.print(" ");
					}
				}

			}
			out.println();

		}

	}

}