#include "stdafx.h"
#include <iostream>
#include <vector>
using namespace std;
int _tmain(int argc, _TCHAR* argv[])
{
int m,n;
cin >>m >> n;
vector<vector<int> > vec(m, vector<int>(n));
int count = 1;
int startx = 0;
int starty = 0;
int endx = m - 1;
int endy = n - 1;
int i, j;
while (startx <= endx && starty<=endy){
for (j = starty; j <= endy; j++){
vec[startx][j] = count++;
}
for (i = startx+1; i <= endx; i++){
vec[i][endy] = count++;
}
for (j = endy - 1; j >= starty; j--){
vec[endx][j] = count++;
}
for (i = endx - 1; i > startx; i--){
vec[i][starty] = count++;
}
startx++;
starty++;
endx--;
endy--;
}
for (i = 0; i < m; i++){
for (j = 0; j < n; j++){
cout << vec[i][j] << ends;
}
cout << endl;
}
return 0;
}