#include<bits/stdc++.h>
using namespace std;
int n,m,k;
int a[10][10];
int fx[4]={0,1,0,-1};
int fy[4]={1,0,-1,0};
void dfs(int x,int y){
k++;
// cout<<k;
a[x][y]=k;
for(int i=0;i<=3;i++){
int tx=x+fx[i];
int ty=y+fy[i];
if(tx>=1&&tx<=n&&ty>=1&&ty<=m&&a[tx][ty]==0){
dfs(tx,ty);
}
}
}
int main(){
cin>>n>>m;
for(int i=1;i<=n;i++){
for(int j=1;j<=m;j++){
a[i][j]=0;
}
}
dfs(1,1);
for(int i=1;i<=n;i++){
for(int j=1;j<=m;j++){
cout<<setw(3)<<a[i][j];
}
cout<<endl;
}
return 0;
}
// 1 2 3 4 5
//1
//2 x 0,1
//3 1 0
//4
/**************************************************************
Problem: 1586
User: chenjingqi
Language: C++
Result: Accepted
Time:50 ms
Memory:2072 kb
****************************************************************/