#include <stdio.h>
#include <stdlib.h>



int main(){
    int i,j,k;
    int a,b;
    int **mat;
    scanf("%d %d",&a,&b);

	if ((mat = (int **)malloc(sizeof(int *)*a)) == NULL){
		printf("ERROR\n"); return 0;
	}
	for(i = 0;i < a;i++){
		if ((mat[i] = (int *)malloc(sizeof(int)*b)) == NULL){
			printf("ERROR\n"); return 0;
		}
	}

	int count = 1;
	for(i =0;i < a;i++){
		for(j = 0;j < b;j++){
			mat[i][j] = count++;
		}
	}
	
    for(i=0;i<a;i++){
        for(j=0;j<b;j++){
            printf("%d ",mat[i][j]);
        }
        printf("\n");
    }
    
    for(i = 0;i < a;i++){
    	free(mat[i]);
    }
    free(mat);


    return 0;
}
