import java.util.Scanner;
public class Main{
public static void main(String[] args)
{
Scanner sc = new Scanner(System.in);
int n = sc.nextInt(), m = sc.nextInt();
int [][] res = new int [n][m];
int [] dx = {-1,0,1,0};
int [] dy = {0,1,0,-1};
int x = 0, y = 0, d = 1; //注意一开始的坐标,左上角是x=0,y=0
//向下是x正方向,向右是y正方向,d=0就是y正,d=1是x正,d=2是y负,d=3是x负
//另外,变换方向顺序为0->1->2->3->0->1->2->3,变换方向的触发条件需要注意
for(int i = 1;i<=n*m;i++)
{
res[x][y] = i; //注意这里是res[x][y]=1;而不是res[m][n] =1;
int a = x + dx[d], b = y + dy[d];
if(a<0||a>=n||b<0||b>=m || res[a][b]>0) //注意这里五个条件
{
d = (d+1)%4;
a = x + dx[d];
b = y + dy[d];
}
x = a;
y = b;
}
for(int[] row:res)
{
for(int val: row) //一定要注意这行不是int[] val
{
System.out.printf("%d ",val);
}//对于每一行的从第一列到最后一列
System.out.println();
}
// for(int i =0;i<n;i++){
// for(int j =0;j<n;j++)
// {
// System.out.printf("%d ", res[i][j]);
// }
// System.out.println();
}
}