program problem_b;

{$APPTYPE CONSOLE}
var
 f:TextFile;
 n,m,i,j,k,o,oo:byte;
 x,y:word;
 a:array[1..40,1..40] of byte;
 s:array[1..201,1..321] of char;
 empty:boolean;
 last,first,up,down:word;
begin
 assignfile(f,'input.txt');
 reset(f);
 read(f,n,m);
 for i:=n downto 1 do
  for j:=1 to m do
   read(f,a[i,j]);
 closefile(f);

 for y:=1 to n*3+m*2+1 do
  for x:=1 to m*4+n*2+1 do
   s[y,x]:='.';
 for i:=n downto 1 do
  for j:=1 to m do
   for k:=1 to a[i,j] do
    begin
     {рисуем очередной куб}
     y:=1+(i-1)*2+(k-1)*3;
     x:=1+(i-1)*2+(j-1)*4;
     s[y,x]:='+';
     s[y,x+1]:='-';
     s[y,x+2]:='-';
     s[y,x+3]:='-';
     s[y,x+4]:='+';
     s[y+3,x]:='+';
     s[y+3,x+1]:='-';
     s[y+3,x+2]:='-';
     s[y+3,x+3]:='-';
     s[y+3,x+4]:='+';
     s[y+1,x]:='|';
     s[y+2,x]:='|';
     s[y+1,x+4]:='|';
     s[y+2,x+4]:='|';
     s[y+4,x+1]:='/';
     s[y+5,x+2]:='+';
     s[y+4,x+5]:='/';
     s[y+5,x+6]:='+';
     s[y+5,x+3]:='-';
     s[y+5,x+4]:='-';
     s[y+5,x+5]:='-';
     s[y+1,x+5]:='/';
     s[y+2,x+6]:='+';
     s[y+3,x+6]:='|';
     s[y+4,x+6]:='|';
     for o:=1 to 3 do
      for oo:=1 to 2 do
       s[y+oo,x+o]:=' ';
     for o:=2 to 4 do
      s[y+4,x+o]:=' ';
     for o:=2 to 3 do
      s[y+o,x+5]:=' ';   
    end;




 assignfile(f,'output.txt');
 rewrite(f);

{ last:=m*4+n*2+1;
 first:=1;
 up:=1;
 down:=n*3+m*2+1;
 empty:=True;
 while (empty)and(first<=last) do
  begin
   for y:=up to down do
    if s[y,first]<>'.' then
     empty:=False;
   if empty then Inc(first);
  end;
 if (first<=last) then
  begin
   empty:=true;
   while (empty)and(last>=first) do
    begin
     for y:=up to down do
      if s[y,last]<>'.' then
       empty:=False;
     if empty then Dec(last);
    end;

  end;
 if last<first then
  down:=up
 else
  begin
   empty:=True;
   while (empty)and(up<=down) do
    begin
     for x:=first to last do
      if s[up,x]<>'.' then
       empty:=False;
     if empty then
      Inc(up);
    end;
   empty:=True;
   while (empty)and(down>=up) do
    begin
     for x:=first to last do
      if s[down,x]<>'.' then
       empty:=false;
     if empty then Dec(down);
    end;
  end;

 for y:=down downto up do
  begin
   for x:=first to last do
    write(f,s[y,x]);
   writeln(f);
  end;}

 empty:=True;
 for y:=n*3+m*2+1 downto 1 do
  begin
   if empty then
    for x:=1 to m*4+n*2+1 do
     if s[y,x]<>'.' then
      empty:=False;
   if not(empty) then
    begin
     for x:=1 to m*4+n*2+1 do
      write(f,s[y,x]);
     if y>1 then writeln(f);
    end;
  end;

 closefile(f);
end.
