program b;

{$APPTYPE CONSOLE}

uses
SysUtils;

var
ms:array[0..250,0..250] of char;
A:array[0..40,0..40] of integer;
N,M:integer;
i,j,k:integer;
f:text;
x0,y0,Amax,Xmax,Ymax,Xt,Yt,dx,dy:integer;
s:string;
flag:boolean;
procedure cub (x,y:integer);
 var
 i:integer;
 j:integer;
begin
 for i:=1 to 2 do
  begin
  ms[x,y-i]:='|';
  ms[x+4,y-i]:='|';
  ms[x+6,y-(2+i)]:='|';
  end;
 for i:=1 to 3 do
  begin
  ms[x+i,y]:='-';
  ms[x+i,y-3]:='-';
  ms[x+i+2,y-5]:='-';
  end;
  {+}
  ms[x,y]:='+';
  ms[x,y-3]:='+';
  ms[x+4,y]:='+';
  ms[x+4,y-3]:='+';
  ms[x+6,y-2]:='+';
  ms[x+6,y-5]:='+';
  ms[x+2,y-5]:='+';
  {/}
  ms[x+1,y-4]:='/';
  ms[x+5,y-4]:='/';
  ms[x+5,y-1]:='/';
  { }
  for i:=1 to 3 do
   for j:=1 to 2 do
    ms[x+i,y-j]:=' ';

  for i:=1 to 3 do
   begin
   ms[x+i+1,y-4]:=' ';
   end;

  for i:=1 to 2 do
   ms[x+5,y-i-1]:=' ';

end;

begin
{input}
assignfile(f,'input.txt');reset(f);
readln(f,N,M);
Amax:=0;
for i:=1 to n do
 for j:=1 to m do
  begin
  read(f,A[i,j]);
  if A[i,j]>Amax then Amax:=A[i,j];
  end;
 closefile(f);

Xmax:=1+M*4+N*2;
Ymax:=1+N*2+3*Amax;
{input ms}
for i:=1 to Xmax do
 for j:=1 to Ymax do
  ms[i,j]:='.';

x0:=N*2-1;
y0:=Amax*3+3;

xt:=x0;yt:=y0;
dx:=4;dy:=3;
{account}
 for k:=1 to Amax do
  begin
  for i:=1 to m do
    begin
    for j:=1 to n do
     begin
     if A[j,i]>=k then cub(xt+4*(i-1)-2*(j-1),yt+2*(j-1)-3*(k-1));
     end;
    end;
  end;
k:=1;
flag:=true;
while flag do
 begin
 for i:=1 to xmax do
    if ms[i,k]<>'.' then begin flag:=false; break;end  ;
 if flag then inc(k);
 end;

assignfile(f,'output.txt');rewrite(f);
 for j:=k to Ymax do
  begin
  s:='';
   for i:=1 to Xmax do
   begin
   s:=s+ms[i,j];
   end;
   if j<Ymax then writeln(f,s)else write(f,s);
 end;

closefile(f);

end.
