program Project1;

{$APPTYPE CONSOLE}

uses
  SysUtils;

var
  m,n,t,k,maxx,maxy,yy,xx,y,x,z,maxz:integer;
  a:array[1..300,1..300]of char;
  b:array[1..40,1..40,1..40]of boolean;

procedure cube(x,y:integer);
procedure proc(x,y:integer;s:string);
var
  i:byte;
begin
  for i:=0 to length(s)-1 do begin
    a[y,x+i]:=s[i+1];
    if x+i>maxx then maxx:=x+i;
  end;
  if y>maxy then maxy:=y;
end;
begin
  proc(x,y,'+---+');
  proc(x,y+1,'|   |/');
  proc(x,y+2,'|   | +');
  proc(x,y+3,'+---+ |');
  proc(x+1,y+4,'/   /|');
  proc(x+2,y+5,'+---+');
end;

begin
  maxz:=0;
  assign(input,'input.txt');
  reset(input);
  assign(output,'output.txt');
  Rewrite(Output);

  FillChar(a,sizeof(a),'.');
  read(n,m);
  for y:=1 to n do begin
    for x:=1 to m do begin
      read(t);
      if t>maxz then maxz:=t;
      for k:=1 to t do
        b[n-y+1,x,k]:=true;
    end;
//    readln;
  end;

  for z:=1 to maxz do
    for y:=n downto 1 do
      for x:=1 to m do begin
        if b[y,x,z] then cube(4*(x-1)+2*(y-1)+1,3*(z-1)+2*(y-1)+1);
      end;


  for yy:=maxy downto 1 do begin
    for xx:=1 to maxx do
      write(a[yy,xx]);
    writeln;
  end;
  Close(Input);
  Close(Output);
end.
