N,M=map(int, input().split()) p=2**N;q=2**M ans=[[-1]*q for _ in range(p)] now=0 for i in range(p//2): for j in range(q//2): ii=2*i;jj=2*j ans[ii][jj]=now ans[ii+1][jj+1]=now+1 ans[ii][jj+1]=now+2 ans[ii+1][jj]=now+3 now+=4 for i in ans: print(*i)