#include <windows.h>
#include <stdio.h>
#include <stdlib.h>

char cube[6][7] = { 0,   0,   '+', '-', '-', '-', '+',
					0,   '/', ' ', ' ', ' ', '/', '|',
					'+', '-', '-', '-', '+', ' ', '|',
					'|', ' ', ' ', ' ', '|', ' ', '+',
					'|', ' ', ' ', ' ', '|', '/', 0,
					'+', '-', '-', '-', '+', 0,   0 };


//#define TESTPATH	"H:\\B\\Debug\\"
#define TESTPATH	""
int main(void)
{
	FILE * inf = fopen(TESTPATH"input.txt", "rt");
	FILE * outf = fopen(TESTPATH"output.txt", "wt");

	int N,M;

	fscanf(inf, "%d", &N);
	fscanf(inf, "%d", &M);

	#define directM(r,c)	m[(r) * M + (c)] 
	#define Z(x,y)			directM(N - (y) - 1, (x))

	int * m = (int*)malloc(M*N*sizeof(int));
	int NM = N*M;

	for (int i = 0; i < NM; i++) {
		fscanf(inf, "%d", &m[i]);
		m[i]--;
	}

	//ok we have the matrix => calc 2D xmax,ymax
	#define projx(x,y,z)	(4 * (x) + 2 * (y))
	#define projy(x,y,z)	(2 * (y) + 3 * (z))

	int xmax = 0, ymax = 0;

//	printf("%d %d\n", projx(0,0,1), projy(0,0,1));

	for (int y = 0; y < N; y++) {
		for (int x = 0; x < M; x++) {
			int tx = projx(x + 1,y + 1,Z(x,y) + 1);
			int ty = projy(x + 1,y + 1,Z(x,y) + 1);

			if (xmax < tx) xmax = tx;
			if (ymax < ty) ymax = ty;
		}
	}

	int xsiz = xmax + 1, ysiz = ymax + 1;

	char * canvas = (char*)malloc(xsiz * ysiz * sizeof(char));

	memset(canvas, '.', xsiz * ysiz * sizeof(char));
	#define C(x,y)	canvas[(y) * xsiz + (x)]

	//Paint the canvas
	for (y = N - 1; y >= 0; y--) {
		for (int x = 0; x < M; x++) {
			int maxz = Z(x,y);
			for (int z = 0; z <= maxz; z++) {
				int xx = projx(x,y,z),
					yy = projy(x,y,z);

				//Paint a cube;
				for (int dx = 0; dx < 7; dx++) {
					for (int dy = 0; dy < 6; dy++) {
						char c = cube[5 - dy][dx];
						if (c) C(xx + dx, yy + dy) = c;
					}
				}
			}
		}
	}

	for (y = 0; y < ysiz; y++) {
		for (int x = 0; x < xsiz; x++) {
			fprintf(outf, "%c", C(x, ymax - y));
		}
		if (y != ymax) fprintf(outf, "\n");
	}


	fclose(inf);
	fclose(outf);

	return 0;
}