#include<iostream>
using namespace std;
int a5[51][51],h,l,maxh,maxy,x,y,cen;
char c5[1000][1000];
bool c6[1000][1000];
char s[7][6] = { {'+','|','|','+',' ', ' '},{'-','1','1','-','/',' '},{'-','1','1','-','1','+'},
{'-','1','1','-','1','-'},{'+','|','|','+','1','-'},
{' ','/','1','1','/','-'},{' ',' ','+','|','|','+'} };
void draw(int x, int y) {
for (int i = 0; i <= 6; i++) {
for (int j = 0; j <=5; j++) {
if (s[i][j] == ' ') continue;
if (s[i][j] == '1') {
c5[x - 6 + i][y - 2 + j] = ' ';
c6[x - 6 + i][y - 2 + j] = 1;
}
else {
c5[x - 6 + i][y - 2 + j] = s[i][j];
c6[x - 6 + i][y - 2 + j] = 1;
}
}
}
}
int main()
{
cin >> h >> l;
for (int i = 0; i < h; i++)
for (int j = 0; j < l; j++) {
cin >> a5[i][j];
if (a5[i][j] > maxh) maxh = a5[i][j];
}
while (maxh--) {
x = h * 2 + 4 * l-(l-1)*4;
y = h * 2+(cen++)*3;
for (int i = 0; i < h; i++) {
for (int j = 0; j < l; j++) {
if (a5[i][j]) {
draw(x, y);
a5[i][j]--;
maxy = max(maxy,y+3);
}
x += 4;
}
x -= 4 * l+2;
y -= 2;
}
}
x = h * 2 + l * 4;
for (int i = maxy; i >= 0; i--) {
cout << endl;
for (int j = 0; j <= x; j++) {
if (c6[j][i]) cout << c5[j][i];
else cout << '.';
}
}
return 0;
}