#include <iostream>
using namespace std;
const int N = 110;
int a[N][N];
int main()
{
int r,c;
cin >> r >> c;
int left = 0, right = c - 1;
int top = 0, bottom = r - 1;
int k = 1;
while(left <= right || top <= bottom)
{
for(int i = left; i <= right && top <= bottom; i++)//构造最上面一行
{
a[top][i] = k++;
}
top++;
for(int i = top; i <= bottom && left <= right; i++)//构造最右侧一列
{
a[i][right] = k++;
}
right--;
for(int i = right; i >= left && top <= bottom; i--)//构造最下面一行
{
a[bottom][i] = k++;
}
bottom--;
for(int i = bottom; i >= top && left <= right; i--)//构造最左侧一列
{
a[i][left] = k++;
}
left++;
}
for(int i = 0; i < r; i++)
{
for(int j = 0; j < c; j++) cout<< a[i][j] << " ";
cout << endl;
}
return 0;
}
#include<iostream>
using namespace std;
int main()
{
int row=1,col=1,num=1,flag=1;
while(true)
{
if(row==1)
{col++;flag=1;num++;}
if(col==1)
{row++;flag=-1;num++;}
row+=flag,col-=flag,num++;
if(row==20&&col==20)
{
cout<<num;
return 0;
}
}
}