program spiral_count;
const
cN = 50;
cM = 50;
var
i, j, N, M, tN, tM, count, iMiddle, jMiddle: integer;
A: array[1..cN, 1..cM] of integer;
procedure spiral(i1, j1, i_N, jM: integer);
var
_i, _j: integer;
begin
_i := i1;
// if j1 < jM then
for _j := j1 to jM do
begin
A[_i, _j] := count;
inc(count);
end;
// if i1 < i_N then
for _i := i1+1 to i_N do
begin
A[_i, _j] := count;
inc(count);
end;
if i1+1 < i_N then // вторая строка
for _j := jM-1 downto j1 do
begin
A[_i, _j] := count;
inc(count);
end;
if (j1+1) < jM then // второй столбец
for _i := i_N-1 downto i1 + 1 do
begin
A[_i, _j] := count;
inc(count);
end;
end;
begin
readln(N, M);
tN := N;
tM := M;
iMiddle := N div 2;
jMiddle := M div 2;
count := 1;
i := 1;
j := 1;
while i < tN do
while j < tM do
begin
spiral(i, j, tN, tM);
inc(i);
inc(j);
dec(tN);
dec(tM);
end;
for i := 1 to N do begin
for j := 1 to M do
write( A[i,j]:3 );
writeln;
end;
end.