import java.io.PrintWriter;
import java.io.FileOutputStream;
import java.io.File;
import java.io.FileNotFoundException;
import java.util.Scanner;

public class table_petr {
    int[][] cells;
    String[] output;

    void readInput() throws FileNotFoundException {
        Scanner scanner = new Scanner(new File("table.in"));

        int numLines = scanner.nextInt();

        assert(numLines >= 1 && numLines <= 100);

        cells = new int[numLines][];

        for (int i = 0; i < numLines; ++i) {
            int numCells = scanner.nextInt();

            assert(numCells >= 1 && numCells <= 10);

            cells[i] = new int[numCells];

            for (int j = 0; j < numCells; ++j) {
                int cellSize = scanner.nextInt();

                assert(cellSize >= 1 && cellSize <= 20);

                cells[i][j] = cellSize;
            }
        }
    }

    void solve() {
        output = new String[2 * cells.length + 1];

        for (int i = 0; i < cells.length; ++i) {
            int[] line = cells[i];

            StringBuilder builder = new StringBuilder();

            for (int cellSize : line) {
                builder.append('|');
                for (int j = 0; j < cellSize; ++j)
                    builder.append(' ');
            }
            builder.append('|');

            output[2 * i + 1] = builder.toString();
        }

        for (int i = 0; i < output.length; i += 2) {
            String prevLine;
            String nextLine;

            if (i > 0)
                prevLine = output[i - 1];
            else
                prevLine = "";

            if (i < output.length - 1)
                nextLine = output[i + 1];
            else
                nextLine = "";

            StringBuilder builder = new StringBuilder();

            for (int j = 0; j < Math.max(prevLine.length(), nextLine.length()); ++j) {

                if (j < prevLine.length() && prevLine.charAt(j) == '|' || j < nextLine.length() && nextLine.charAt(j) == '|')
                    builder.append("+");
                else
                    builder.append("-");
            }

            output[i] = builder.toString();
        }
    }

    void writeOutput() throws FileNotFoundException {
        PrintWriter writer = new PrintWriter(new FileOutputStream("table.out"));
        for (String aOutput : output)
            writer.println(aOutput);
        writer.close();

    }

    void run() throws FileNotFoundException {
        readInput();
        solve();
        writeOutput();
    }

    public static void main(String[] args) throws FileNotFoundException {
        new table_petr().run();
    }
}
