program D_B;

{$APPTYPE CONSOLE}

Var
  A: array [1..50, 1..50] of integer;
  Res: array [1..301, 1..301] of char;
  N, M, i, j, k, ResW, ResH: integer;
  f: boolean;
  fi, fo: text;

Const
  Cube: array [1..6, 1..7] of char = (
    '..+---+',
    './   /|',
    '+---+ |',
    '|   | +',
    '|   |/.',
    '+---+..');

procedure Tower(j, i, h: integer);
var ax, ay, x, y, z: integer;
begin
  ay := 1 + (N-j)*2;
  ax := 1 + (N-j)*2 + (i-1)*4;
  for z := 1 to h do begin
    for y := 1 to 6 do
      for x := 1 to 7 do
	if Cube[7-y,x] <> '.' then
	  Res[ay+y-1, ax+x-1] := Cube[7-y,x];
    Inc(ay, 3);
  end;
end;

begin
  Assign(fi, 'INPUT.TXT'); Reset(fi);
  Read(fi, N, M);
  ResW := (4*M+1) + (2*N);
  for j := 1 to N do
    for i := 1 to M do
      Read(fi, A[j,i]);
  FillChar(Res, SizeOf(Res), '.');
  for j := 1 to N do
    for i := 1 to M do
      for k := 1 to A[j,i] do
	Tower(j, i, k);
  ResH := 4 + 2*N;
  for j := 301 downto 1 do begin
    f := true;
    for i := 1 to ResW do
      if Res[j,i] <> '.' then f := false;
    if not f then begin ResH := j; Break; end;
  end;
{
  for j := 1 to ResH do
    for i := 1 to ResW do
      if Res[j,i] = ' ' then Res[j,i] := #0;
}
  Assign(fo, 'OUTPUT.TXT'); Rewrite(fo);
  for j := ResH downto 1 do begin
    for i := 1 to ResW do Write(fo, Res[j,i]);
    if j <> 1 then Writeln(fo);
  end;
  Close(fi);
  Close(fo);
end.