#include<stdio.h>
#include<string.h>
int main()
{
int n,m,a[][];
while(scanf("%d%d",&n,&m)!=EOF)
{ int t,i,j;
t=a[i=][j=]=;
while(t<n*m)
{
while(j+<m)
a[i][++j]=++t;
a[++i][j]=++t;
while(j->=)
a[i][--j]=++t;
a[++i][j]=++t;
} for(int i=;i<n;i++)
{
for(int j=;j<m-;j++)
{
printf("%2d ",a[i][j]);
}
printf("%2d\n",a[i][m-]);
}
} return ;
}