#include const int bit[21] = {1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768, 65536, 131072, 262144, 524288, 1048576}; int check(int n, int m, int A[][2048]) { int i, j, ii, jj; for (i = 0; i < n; i++) { for (ii = i + 1; ii < n; ii++) { for (j = 0; j < m; j++) { for (jj = 0; jj < m; jj++) if ((A[i][j] ^ A[i][jj] ^ A[ii][j] ^ A[ii][jj]) != 0) return 0; } } } return 1; } int main() { int n, m; scanf("%d %d", &n, &m); int i, j, k, A[2048][2048]; for (i = 0, k = 0; i < bit[n]; i++) for (j = 0; j < bit[m]; j++) A[i][j] = k++; // printf("%d\n", check(n, m, A)); for (i = 0; i < bit[n]; i++) { for (j = 0; j < bit[m] - 1; j++) printf("%d ", A[i][j]); printf("%d\n", A[i][j]); } fflush(stdout); return 0; }