{$apptype console}

uses Math;

const
  _MAX = 2000;

var
  a: array[0..40, 0..40] of integer;
  i, j, k: integer;
  m, n, z: integer;
  c: array[0.._MAX, 0.._MAX] of char;
  mm: integer;
  mx, my: integer;

procedure DrawCube(x, y, z: integer);
const
  cube: array[0..5, 0..6] of char = (
    '..+---+',
    './   /|',
    '+---+ |',
    '|   | +',
    '|   |/.',
    '+---+..'
  );

var
  i, j, k: integer;
  xx, yy: integer;
begin
  xx := 4*x + 2*y;
  yy := 3*z + 2*y;

  for i := 0 to 5 do
    for j := 0 to 6 do
      if cube[i, j] <> '.' then begin
        c[xx + j, yy + 5 - i] := cube[i, j];
        mx := Max(mx, xx + j);
        my := Max(my, yy + i);
      end;
end;

begin
  assign(input, 'input.txt');
  reset(input);
  assign(output, 'output.txt');
  rewrite(output);

  fillchar(a, sizeof(a), false);
  read(n, m);
  mm := 1;
  for i := 0 to n - 1 do
    for j := 0 to m - 1 do begin
      Read(a[j, i]);
      mm := max(mm, a[j, i]);
    end;

  mx := 0;
  my := 0;
  fillchar(c, sizeof(c), '.');
  for i := 0 to mm - 1 do begin
    for k := n - 1 downto 0 do
      for j := 0 to m - 1 do
        if a[j, n - k - 1] > i then DrawCube(j, k, i);
  end;

  for i := my downto 0 do begin
    for j := 0 to mx do
      Write(c[j, i]);
    WriteLn;
  end;

  close(input);
  close(output);
end.