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.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class DrawBrackets {
    private Bracket[] brackets;
    private char[][] map;
    private int center;
    
    public static void main(String[] args) {
        try(BufferedReader reader = new BufferedReader(new InputStreamReader(System.in))) {
            int numberOfBrackets = Integer.parseInt(reader.readLine().trim());
            String lineOfBrackets = reader.readLine();
            DrawBrackets drawBrackets = new DrawBrackets(numberOfBrackets, lineOfBrackets);
            drawBrackets.draw();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
    
    public DrawBrackets(int numberOfBrackets, String inputBrackets) {
        StringBuilder buildBrackets = new StringBuilder();
        for (int i = 0; i < numberOfBrackets; i++) {
            buildBrackets.append(inputBrackets.charAt(i));
        }
        String lineOfBrackets = buildBrackets.toString();
        this.brackets = new Bracket[numberOfBrackets];
        int bracketCoordinate = -1;
        int level = 0;
        int maxLevel = 0;
        Bracket.BracketType previousBracket = null;
        for (int i = 0; i < lineOfBrackets.length(); i++) {
            Bracket.BracketType bracketType = Bracket.BracketType.valueOf(lineOfBrackets.charAt(i));
            bracketCoordinate++;
            if (bracketType == Bracket.BracketType.LEFT) {
                if (Bracket.BracketType.LEFT.equals(previousBracket)) {
                    level++;
                }
            }
            if (bracketType == Bracket.BracketType.RIGHT ) {
                if (Bracket.BracketType.LEFT.equals(previousBracket)) {
                    bracketCoordinate += 3; // whitespaces + bracket's edges
                } else {
                    level--;
                }
            }
            maxLevel = Math.max(maxLevel, level);
            brackets[i] = new Bracket(level, bracketCoordinate, bracketType);
            previousBracket = bracketType;
        }
        for (Bracket bracket : brackets) {
            int currentLevel = bracket.getLevel();
            bracket.setLevel(Math.abs(currentLevel - maxLevel));
        }
        map = new char[3 + maxLevel * 2][bracketCoordinate + 1];
        center = maxLevel + 1;
    }
    
    public void draw() {
        fillMap();
        StringBuilder lineOfImage = new StringBuilder();
        for (int i = 0; i < map.length; i++) {
            for (int j = 0; j < map[0].length; j++) {
                if (map[i][j] == 0) {
                    map[i][j] = ' ';
                }
                lineOfImage.append(map[i][j]);
            }
            if (i != map.length - 1) {
                lineOfImage.append('\n');
            }
            System.out.print(lineOfImage.toString());
            lineOfImage.setLength(0);
        }
    }
    
    private void fillMap() {
        for (Bracket bracket : brackets) {
            insertBracket(bracket);
        }
    }
    
    private void insertBracket(Bracket bracket) {
        int level = bracket.getLevel();
        int coordinate = bracket.getCoordinate();
        for (int i = 0; i <= level; i++) {
            map[center + i][coordinate] = '|';
            map[center - i][coordinate] = '|';
        }
        map[center + level + 1][coordinate] = '+';
        map[center - level - 1][coordinate] = '+';
        if (bracket.getBracketType() == Bracket.BracketType.LEFT) {
            map[center + level + 1][coordinate + 1] = '-';
            map[center - level - 1][coordinate + 1] = '-';
        } else {
            map[center + level + 1][coordinate - 1] = '-';
            map[center - level - 1][coordinate - 1] = '-';
        }
        
    }
}

class Bracket {
    private int level;
    private int coordinate;
    private BracketType bracketType;
    
    public Bracket(){}
    
    public Bracket(int level, int coordinate, BracketType bracketType) {
        this.level = level;
        this.coordinate = coordinate;
        this.bracketType = bracketType;
    }
    
    public int getLevel() {
        return level;
    }
    
    public void setLevel(int level) {
        this.level = level;
    }
    
    public int getCoordinate() {
        return coordinate;
    }
    
    public void setCoordinate(int coordinate) {
        this.coordinate = coordinate;
    }
    
    public BracketType getBracketType() {
        return bracketType;
    }
    
    public void setBracketType(BracketType bracketType) {
        this.bracketType = bracketType;
    }
    
    public enum BracketType {
        LEFT {
            @Override
            public char getCharValue() {
                return '[';
            }
        }, 
        RIGHT {
            @Override
            public char getCharValue() {
                return ']';
            }
        };
        
        public abstract char getCharValue();
        
        public static BracketType valueOf(char bracket) {
            for (BracketType bracketType : BracketType.values()) {
                if (bracketType.getCharValue() == bracket) {
                    return  bracketType;
                }
            }
            throw new IllegalArgumentException();
        }
    }
}