program BBB;

{$APPTYPE CONSOLE}
var q:array[0..1000,0..1000] of char;
    a:array[1..100,1..100,1..100] of boolean;
         //  x      y     h
    n,m:integer;
    MaxY:integer=0;
    MaxX:integer=0;
    maxh:integer;

const cubestr:array[0..5] of string [8]=(
   '+---+..',
   '|   |/.',
   '|   | +',
   '+---+ |',
   './   /|',
   '..+---+');

procedure cube(x,y,z:integer);
var
  i,j:integer;
  scrx, scry:integer;
begin
  scrx:=4*(x-1)+2*(z-1);
  scry:=3*(y-1)+2*(z-1);
  for i:=0 to 5 do
    for j:=1 to 7 do
      if cubestr[i][j]<>'.' then
        begin
          q[scry+i, scrx+j-1]:=cubestr[i][j];
          if scry+i>MaxY then
            MaxY:=scry+i;
          if scrx+j-1>MaxX then
            MaxX:=scrx+j-1;
        end;
end;

Procedure Clear;
var i,j,k:integer;
begin
  for i:=0 to 1000 do
    for j:=0 to 1000 do
      q[i,j]:='.';
  for i:=1 to 100 do
  for j:=1 to 100 do
  for k:=1 to 100 do a[i,j,k]:=false;
end;

procedure DoInput;
var
  x,y,z,i:integer;
  // r,c,h,i:integer;
begin
  AssignFile(input,'input.txt');
  Reset(input);
  ReadLn(n,m);
  maxh:=0;
  for z:=n downto 1 do
  begin
    for x:=1 to m do
    begin
      Read(y);
      if maxh<y then
        maxh:=y;
      for i:=1 to y do
        a[x,i,z]:=true;
    end;
    ReadLn;
  end;

  CloseFile(input);
end;

procedure Calc;
var
  x,y,z:integer;
begin
  for y:=1 to maxH do
    for z:=n downto 1 do
      for x:=1 to m do
        if a[x,y,z] then
          cube(x,y,z);
end;

procedure DoOutput;
var
  i,j:integer;
  x,y,z:integer;
begin
  AssignFile(output,'output.txt');
  Rewrite(output);

{  for x:=1 to m do
    begin
      for z:=1 to n do
        if a[x,1,z] then
          write('+')
        else
          write(' ');

      writeln;
    end;
}

  For i:=MaxY downto 0 do
    begin
      For j:=0 to MaxX do
        write(q[i,j]);
{      if i<>0 then}
        Writeln;
    end;
  CloseFile(Output);
end;

begin
  Clear;
  DoInput;
  calc;

  DoOutput;
end.
