''' 問題文============================================================ ================================================================= 解説============================================================= ================================================================ ''' import numpy as np n,x,y,z = input().strip().split(' ') n,x,y,z =[int(n),int(x),int(y),int(z)] x-=1 y-=1 if n == 4: ans = np.array([ [1,14,4,15], [8,11,5,10], [13,2,16,3], [12,7,9,6], ]) elif n == 8: ans = array([[ 1, 16, 57, 56, 33, 48, 25, 24], [63, 50, 7, 10, 31, 18, 39, 42], [ 8, 9, 64, 49, 40, 41, 32, 17], [58, 55, 2, 15, 26, 23, 34, 47], [ 5, 12, 61, 52, 37, 44, 29, 20], [59, 54, 3, 14, 27, 22, 35, 46], [ 4, 13, 60, 53, 36, 45, 28, 21], [62, 51, 6, 11, 30, 19, 38, 43]]) else: ans = np.array([[ 1, 248, 61, 204, 49, 200, 13, 252, 17, 232, 45, 220, 33, 216, 29, 236], [255, 10, 195, 54, 207, 58, 243, 6, 239, 26, 211, 38, 223, 42, 227, 22], [196, 53, 256, 9, 244, 5, 208, 57, 212, 37, 240, 25, 228, 21, 224, 41], [ 62, 203, 2, 247, 14, 251, 50, 199, 46, 219, 18, 231, 30, 235, 34, 215], [193, 56, 253, 12, 241, 8, 205, 60, 209, 40, 237, 28, 225, 24, 221, 44], [ 63, 202, 3, 246, 15, 250, 51, 198, 47, 218, 19, 230, 31, 234, 35, 214], [ 4, 245, 64, 201, 52, 197, 16, 249, 20, 229, 48, 217, 36, 213, 32, 233], [254, 11, 194, 55, 206, 59, 242, 7, 238, 27, 210, 39, 222, 43, 226, 23], [ 65, 184, 125, 140, 113, 136, 77, 188, 81, 168, 109, 156, 97, 152, 93, 172], [191, 74, 131, 118, 143, 122, 179, 70, 175, 90, 147, 102, 159, 106, 163, 86], [132, 117, 192, 73, 180, 69, 144, 121, 148, 101, 176, 89, 164, 85, 160, 105], [126, 139, 66, 183, 78, 187, 114, 135, 110, 155, 82, 167, 94, 171, 98, 151], [129, 120, 189, 76, 177, 72, 141, 124, 145, 104, 173, 92, 161, 88, 157, 108], [127, 138, 67, 182, 79, 186, 115, 134, 111, 154, 83, 166, 95, 170, 99, 150], [ 68, 181, 128, 137, 116, 133, 80, 185, 84, 165, 112, 153, 100, 149, 96, 169], [190, 75, 130, 119, 142, 123, 178, 71, 174, 91, 146, 103, 158, 107, 162, 87]]) print(ans) kx,ky = np.where(ans==z) kx = int(kx) ky = int(ky) kx += n - y ky += n - x ans = np.concatenate([ans,ans,ans]) ans = np.concatenate([ans,ans,ans],axis=1) ans = ans[kx:kx+n,ky:ky+n] print(ans) #for i in range(n): # for j in range(n): # print(ans[i+kx][j+ky],end=" ") # print("")