n,m = map(int, input().split()) li = [[0 for i in range(1 << m)] for i in range(1 << n)] for i in range(1 << n): for j in range(1 << m): li[i][j] = i * (1 << m) + j for i in range(1 << n): print(*li[i])