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

// 必要があれば変数などを追加してもOKです

int main(){
    int i, j;
    int a, b;
    int **mat;

    scanf("%d %d", &a, &b);

    // ここで2次元配列の動的確保をする
    mat = (int **)malloc(sizeof(int *) * a);
    if (mat == NULL) {
        printf("ERROR: memory allocation failed\n");
        return 0;
    }

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

    // ここで2次元配列に数値を代入する（例：i + j）
    for (i = 0; i < a; i++) {
        for (j = 0; j < b; j++) {
            mat[i][j] = i + j;
        }
    }

    // 以下の部分は表示の部分です
    // いじらなくてOK
    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;
}
