program Zz;
//uses windows;
var f,f2:text;
    left,right,h,w,max,n,m,t,t2,t3,t4:integer;
    ma:array[0..41,0..41] of integer;

    res:array[1..480,1..480] of char;

procedure DoIT(x,y:integer);
begin
 res[y,x]:=char(43);
 res[y,x+4]:=char(43);
 res[y-3,x]:=char(43);
 res[y-3,x+4]:=char(43);
 res[y-3,x+5]:=char(32);
 res[y-3,x+6]:=char(124);


 res[y-4,x+1]:=char(47);
 res[y-4,x+2]:=char(32);
 res[y-4,x+3]:=char(32);
 res[y-4,x+4]:=char(32);
 res[y-4,x+5]:=char(47);
 res[y-4,x+6]:=char(124);

 res[y,x+1]:=char(45);
 res[y,x+2]:=char(45);
 res[y,x+3]:=char(45);

 res[y-3,x+1]:=char(45);
 res[y-3,x+2]:=char(45);
 res[y-3,x+3]:=char(45);

 res[y-1,x]:=char(124);
 res[y-1,x+1]:=char(32);
 res[y-1,x+2]:=char(32);
 res[y-1,x+3]:=char(32);
 res[y-1,x+4]:=char(124);
 res[y-1,x+5]:=char(47);



 res[y-2,x]:=char(124);
 res[y-2,x+1]:=char(32);
 res[y-2,x+2]:=char(32);
 res[y-2,x+3]:=char(32);
 res[y-2,x+4]:=char(124);
 res[y-2,x+5]:=char(32);
 res[y-2,x+6]:=char(43);

 res[y-5,x+2]:=char(43);
 res[y-5,x+3]:=char(45);
 res[y-5,x+4]:=char(45);
 res[y-5,x+5]:=char(45);
 res[y-5,x+6]:=char(43);

end;

begin
  //allocconsole;

  assignfile(f,'input.txt');
  reset(f);
  assignfile(f2,'output.txt');
  rewrite(f2);
  read(f,n,m);

  fillchar(ma,sizeof(ma),0);
  max:=0;

  for t:=1 to n do
   for t2:=1 to m do
    begin read(f,ma[t,t2]); if ma[t,t2]>max then max:=ma[t,t2] end;

  h:=n*3+max*4+2;
  w:=m*4+n*3+2;

  fillchar(res,sizeof(res),46);
                         


  //doit(1,380);
  for t3:=1 to max do begin

  for t:=1 to n do
   begin
    for t2:=1 to m do
     begin
       if ma[t,t2]<>0 then begin Doit(3*(n-t)+4*(t2-1)+t+1, 380-2*(n-t)-(t3-1)*3); dec(ma[t,t2]) end;
     end;
   end;

  end;

  {
 for t:=380-h to 380 do
  begin
   for t2:=1 to w do write(f2,res[t,t2]);
   if t<>380 then writeln(f2,'');
  end;
  }
  t4:=0;



  for t:=380-h to 380 do
  begin
   for t2:=1 to w do
    if res[t,t2]<>'.' then begin t4:=t; break end;
    if t4<>0 then break;
  end;

  left:=0;
  for t:=1 to w do
  begin
   for t2:=t4 to 380 do
    if res[t2,t]<>'.' then begin left:=t; break end;
    if left<>0 then break;
  end;


  right:=0;
  for t:=w downto 1 do
  begin
   for t2:=t4 to 380 do
    if res[t2,t]<>'.' then begin right:=t; break end;
    if right<>0 then break;
  end;

  if right=0 then right:=w;
  if left=0 then left:=1;
  
  for t:=t4 to 380 do
  begin
   for t2:=left to right do write(f2,res[t,t2]);
   writeln(f2);
  end;
   
  closefile(f2);
//  readln;


end.
