import queue
n,m,x,y=map(int,input().split())
dir=[[2,1],[2,-1],[-2,1],[-2,-1],[1,2],[1,-2],[-1,2],[-1,-2]]
q=queue.Queue()
count=0
def bfs(i,j):
ans=-1
global count
count += 1
q.put((x-1,y-1,0))
vis[x-1][y-1]=1
while q.empty()==False:
now=q.get()
if now[0]==i and now[1]==j:
ans=now[2]
break
for k in range(8):
newx=now[0]+dir[k][0]
newy=now[1]+dir[k][1]
newstep=now[2]+1
if newx>=0 and newx<n and newy>=0 and newy<m and vis[newx][newy]==0:
vis[newx][newy] =1
q.put((newx,newy,newstep))
print('{: <5}'.format(ans), end='')
if count % m == 0:
print()
for i in range(n):
for j in range(m):
vis=[[0 for o in range(m)]for p in range(n)]
bfs(i,j)
q.queue.clear()
试了一个超时的点,print速度好慢。。。