#include<bits/stdc++.h>
using namespace std;
struct node{
int x,y;
};
int main()
{
int n,m,x0,y0,step[405][405],dx[8]={-1,-2,-2,-1,1,2,2,1},dy[8]={-2,-1,1,2,2,1,-1,-2};
cin >> n>>m>>x0>>y0;
memset(step,-1,sizeof(step));
//memset是计算机中C/C++语言初始化函数。作用是将某一块内存中的内容全部设置为指定的值, 这个函数通常为新申请的内存做初始化工作。将step数组初始化为-1
queue<node> q;
step[x0][y0]=0;
node temp={x0,y0},p;
q.push(temp);
while(!q.empty())
{
temp=q.front();
q.pop();
for(int i=0;i<8;i++)
{
int x=dx[i]+temp.x,y=dy[i]+temp.y;
if(x>=1&&x<=n&&y>=1&&y<=m&&step[x][y]==-1)
{
step[x][y]=step[temp.x][temp.y]+1;
p={x,y};
q.push(p);
}
}
}
for(int i=1;i<=n;i++){
for(int j=1;j<=m;j++)
{
cout << step[i][j] << " ";
}
cout <<endl;
}
return 0;
}