import java.io.*;
import java.util.*;

public class kak_u_pakal_gk_slow {
    static int gcd(int a, int b) {
        if (a == 0) {
            return b;
        }
        return gcd(b % a, a);
    }

    static int lcm(int a, int b) {
        return a / gcd(a, b) * b;
    }

    static class Dimension {
        final int size;
        final int extent;

        Dimension(int size, int extent) {
            this.size = size;
            this.extent = extent;
        }

        Dimension unify(Dimension that) {
            int size1 = this.size;
            int size2 = that.size;
            int extent1 = this.extent;
            int extent2 = that.extent;
            while (size1 != size2) {
                //System.out.println(size1 + " " + size2);
                if (size1 < size2) {
                    size1 += extent1;
                } else {
                    size2 += extent2;
                }
            }
            System.out.println(this + " || " + that + " " + new Dimension(size1, lcm(extent1, extent2)));
            return new Dimension(size1, lcm(extent1, extent2));
        }

        Dimension append(Dimension that) {
            return new Dimension(
                this.size + that.size,
                lcm(this.extent, that.extent)
            );
        }

        Dimension dbl() {
            int size = this.size;
            int extent = this.extent;
            if (extent % 4 != 0) {
                while (size % 4 != 0) {
                    size += extent;
                }
                while (extent % 4 != 0) extent *= 2;
            }
            if (size % 2 != 0) {
                throw new RuntimeException("Cannot double");
            }
            //System.out.println(new Dimension(size / 2, extent / 2));
            return new Dimension(size / 2, extent / 2);
        }

        @Override
        public String toString() {
            return size + " + k * " + extent;
        }
    }

    static abstract class Glyph {
        Dimension w;
        Dimension h;

        abstract void init();
        abstract void write(int w, int h, List<StringBuilder> rows);

        @Override 
        public String toString() {
            return "(" + w + ", " + h + ")";
        }
    }

    static class Double extends Glyph {
        final Glyph glyph;

        Double(Glyph glyph) {
            this.glyph = glyph;
        }

        void init() {
            glyph.init();
            w = glyph.w;
            h = glyph.h;
        }

        void write(int w, int h, List<StringBuilder> rows) {
            glyph.write(w, h, rows);
        }
    }

    static class Horz extends Glyph {
        int size;

        final List<Glyph> glyphs;

        Horz(List<Glyph> glyphs) {
            this.glyphs = glyphs;
        }

        void init() {
            size = 0;
            w = new Dimension(0, 1);
            h = new Dimension(0, 1);
            for (Glyph g : glyphs) {
                g.init();
                h = h.unify(g.h);
                if (g instanceof Double) {
                    Double d = (Double) g;
                    w = w.unify(d.w.dbl());
                    size += 2;
                } else {
                    w = w.unify(g.w);  
                    size++;
                }
            }
            w = new Dimension(size * w.size, size * w.extent);
            System.out.println("Horz " + this);
        }

        void write(int w, int h, List<StringBuilder> rows) {
            int cw = w / size;
            for (Glyph g : glyphs) {
                if (g instanceof Double) {
                    g.write(2 * cw, h, rows);
                } else {
                    g.write(cw, h, rows);
                }
            }
        }
    }

    static class Vert extends Glyph {
        final List<Glyph> glyphs;
        int size;

        Vert(List<Glyph> glyphs) {
            this.glyphs = glyphs;
        }

        void init() {
            w = new Dimension(0, 1);
            h = new Dimension(0, 1);
            size = 0;
            for (Glyph g : glyphs) {
                g.init();
                w = w.unify(g.w);
                if (g instanceof Double) {
                    Double d = (Double) g;
                    h = h.unify(d.h.dbl());
                    size += 2;
                } else {
                    h = h.unify(g.h);  
                    size++;
                }
            }
            h = new Dimension(size * h.size, size * h.extent);
            System.out.println("Vert " + this);
        }

        void write(int w, int h, List<StringBuilder> rows) {
            int ch = h / size;
            int t = 0;
            for (Glyph g : glyphs) {
                if (g instanceof Double) {
                    g.write(w, 2 * ch, rows.subList(t, t + 2 * ch));
                    t += 2 * ch;
                } else {
                    g.write(w, ch, rows.subList(t, t + ch));
                    t += ch;
                }
            }
        }
    }

    static void appendHorzLine(StringBuilder row, int w) {
        row.append("+");
        for (int i = 1; i < w - 1; i++) {
            row.append("-");
        }
        row.append("+");
    }

    static void appendVertLine(List<StringBuilder> rows, int h) {
        for (int i = 0; i < h; i++) {
            rows.get(i).append("|");
        }
    }

    static class Leaf extends Glyph {
        final String id;

        Leaf(String id) {
            this.id = " " + id + " ";
        }

        void init() {
            w = new Dimension(2 * id.length() + 2, 2);
            h = new Dimension(4, 1);
            System.out.println(id + " " + this);
        }

        void write(int w, int h, List<StringBuilder> rows) {
            appendHorzLine(rows.get(0), w);
            appendHorzLine(rows.get(h - 1), w);

            appendVertLine(rows.subList(1, h - 1), h - 2);

            StringBuilder row;           
            row = rows.get(1);
            for (int i = 0; i < 2 * id.length(); i++) {
                row.append(id.charAt(i / 2));
            }
            for (int i = 2 * id.length() + 1; i < w - 1; i++) {
                row.append(' ');
            }

            row = rows.get(2);
            for (int i = 0; i < 2 * id.length(); i++) {
                row.append(id.charAt(i / 2));
            }
            for (int i = 2 * id.length() + 1; i < w - 1; i++) {
                row.append(' ');
            }

            for (int i = 3; i < h - 1; i++) {
                row = rows.get(i);
                for (int j = 1; j < w - 1; j++) {
                    row.append(' ');
                }
            }

            appendVertLine(rows.subList(1, h - 1), h - 2);
        }
    }

    static StringTokenizer t;
    static String token;

    static void nextToken() {
        token = t.nextToken();
    }

    static boolean test(String s) {
        if (s.equals(token)) {
            nextToken();
            return true;
        }
        return false;
    }

    static void expect(String s) {
        if (!test(s)) {
            throw new RuntimeException(s + " expected instead of " + token);
        }
    }

    static Glyph parseBlock() {
        Glyph g;
        if (test("[")) {
            g = new Double(parseBlock());
            expect("]");
        } else if (test("(")) {
            List<Glyph> glyphs = new ArrayList<Glyph>();
            glyphs.add(parseBlock());
            if (test(".")) {
                do {
                    glyphs.add(parseBlock());
                } while (test("."));
                g = new Horz(glyphs);
            } else {
                expect(":");
                do {
                    glyphs.add(parseBlock());
                } while (test(":"));
                g = new Vert(glyphs);
            }
            expect(")");
        } else {
            g = new Leaf(token);
            nextToken();
        }
        return g;
    }

    static char process(char ch1, char ch2, char ch3, char ch4) {
        if (ch1 == ch2 && ch2 == ch3 && ch3 == ch4) {
            return ch1;
        } else {
            return '+';
        }
    }

    public static void main(String[] args) throws IOException {
        Scanner scanner = new Scanner(System.in);
        t = new StringTokenizer(scanner.nextLine() + "!!", "():.[]!", true);

        nextToken();
        Glyph root = parseBlock();
        expect("!");

        root.init();
        int w = root.w.size + 2;
        int h = root.h.size + 2;

        List<StringBuilder> rows = new ArrayList<StringBuilder>();
        for (int i = 0; i < h; i++) {
            rows.add(new StringBuilder());
        }

        appendHorzLine(rows.get(0), w);
        appendHorzLine(rows.get(h - 1), w);
        appendVertLine(rows.subList(1, h - 1), h - 2);
        root.write(root.w.size, root.h.size, rows.subList(1, h - 1));
        appendVertLine(rows.subList(1, h - 1), h - 2);

        PrintWriter writer = new PrintWriter(System.out);
        /*
        for (StringBuilder row : rows) {
            System.out.println(row);
        }
        */
        for (int i = 0; 2 * i < h; i++) {
            for (int j = 0; 2 * j < w; j++) {
                writer.print(process(
                    rows.get(2 * i + 0).charAt(2 * j + 0),
                    rows.get(2 * i + 1).charAt(2 * j + 0),
                    rows.get(2 * i + 0).charAt(2 * j + 1),
                    rows.get(2 * i + 1).charAt(2 * j + 1)
                ));
            }
            writer.println();
        }
        writer.close();
    }
}
