program B;

{$APPTYPE CONSOLE}

uses
  SysUtils;
const
   Cube:Array[1..6,1..7] of Char=
     (
     (#0,#0,#43,#45,#45,#45,#43),
     (#0,#47,#32,#32,#32,#47,#124),
     (#43,#45,#45,#45,#43,#32,#124),
     (#124,#32,#32,#32,#124,#32,#43),
     (#124,#32,#32,#32,#124,#47,#0),
     (#43,#45,#45,#45,#43,#0,#0)
     );

var
     N,M:Integer;
     A:Array[1..40,1..40] Of Integer;
     Mass:Array[-1000..1000,-1000..1000] of Char;
     I,J,k:Integer;
     dx,dy:Integer;
     Sum_Dx,Sum_Dy:Integer;
     X,Y:Integer;
     ExY:Integer;

     i1,i2,j1,j2:Integer;
Procedure Install;
Begin
     for i:=-1000 to 1000 Do
         for J:=-1000 to 1000 Do
          Mass[i,j]:=#46;
End;

Procedure PrintCube(x,y:Integer);
var i,j,k:Integer;

Begin
       for i:=1 to 6 Do
       For j:=1 to 7 Do
             if (Cube[i,j]<>#0)Then
               Mass[i+y,j+x]:=Cube[i,j];
End;

procedure findGr;
var i,j:Integer;
  b:Boolean;
Begin
     b:=false;
     for i:=-1000 to 1000 Do Begin
        for j:=-1000 to 1000 Do Begin
           if Mass[i,j]<>#46 Then Begin i1:=i;b:=true;break;End;
      End;
         if b=true Then Break;
      End;
     b:=false;
     for i:=1000 downto -1000 Do Begin
        for j:=-1000 to 1000 Do Begin
           if Mass[i,j]<>#46 Then Begin i2:=i;b:=true;break;End;
      End;
         if b=true Then Break;
      End;

     b:=false;
     for j:=-1000 to 1000 Do Begin
        for i:=-1000 to 1000 Do Begin
           if Mass[i,j]<>#46 Then Begin j1:=j;b:=true;break;End;
      End;
         if b=true Then Break;
      End;

     b:=false;
     for j:=1000 downto -1000 Do Begin
        for i:=-1000 to 1000 Do Begin
           if Mass[i,j]<>#46 Then Begin j2:=j;b:=true;break;End;
      End;
         if b=true Then Break;
      End;


End;

begin
  { TODO -oUser -cConsole Main : Insert code here }
   AssignFile(Input,'input.txt');
   Reset(Input);
   Read(N,M);For i:=1 to N Do For J:=1 to M Do Read(A[i,j]);
   Close(INPUT);
   Install;


   dx:=0;dy:=0;
   Sum_Dx:=0;Sum_Dy:=0;
   for i:=1 To N Do Begin
         For j:=1 to M Do Begin
            X:=Dx+Sum_Dx+1+4*(J-1);
            Y:=Dy+Sum_Dy;ExY:=Y;
            for k:=1 to A[i,j] Do Begin
               PrintCube(X,ExY);
               ExY:=Y-(3*(K));
            End;

         End;
    Sum_Dx:=Sum_Dx-2;Sum_Dy:=Sum_Dy+2;
   End;

   findGr;

   AssignFile(oUTPUT,'oUTPUT.TXT');
   Rewrite(OutPut);
   for i:=i1 to i2 Do Begin
   For j:=j1 to j2 Do Begin
         Write(Mass[i,j]);
     End;
     Writeln;
   End;

   Close(OutPut);

end.
