# 解説が賢い N,X,Y,Z=map(int,input().split()) ANS=[[-1]*N for i in range(N)] for i in range(N): for j in range(N): if i%4==0 or i%4==3: if j%4==0 or j%4==3: ANS[i][j]=i*N+j else: ANS[i][j]=N*N-(i*N+j)-1 else: if j%4==0 or j%4==3: ANS[i][j]=N*N-(i*N+j)-1 else: ANS[i][j]=i*N+j XOR=Z^ANS[X-1][Y-1] for i in range(N): for j in range(N): ANS[i][j]^=XOR ANS[i][j]+=1 for i in range(N): print(*ANS[i])