#include<iostream>
#include<queue>
using namespace std;
struct horse
{
int num;
int x;
int y;
};
int n,m,x,y;
bool flag[10000][10000],flag1;
int time[10000][10000];
queue<horse> q;
int main(){
cin>>n>>m>>x>>y;
for(int i=0;i<n;i++){
for(int j=0;j<m;j++){
time[i][j]=-1;
}
}
horse n1;
n1.x=x;
n1.y=y;
n1.num=0;
flag[n1.x][n1.y]=true;
time[n1.x][n1.y]=0;
q.push(n1);
while(!q.empty()){
n1=q.front();
q.pop();
horse n2=n1;
if(n2.x+1>=0&&n2.x+1<=n&&n2.y+2>=0&&n2.y+2<=n&&flag[x+1][y+2]==false){
n2.x+=1;
n2.y+=2;
flag[n2.x][n2.y]=true;
time[n2.x][n2.y]=n2.num;
q.push(n2);
n2.x-=1;
n2.y-=2;
}
if(n2.x+2>=0&&n2.x+2<=n&&n2.y+1>=0&&n2.y+1<=n&&flag[x+2][y+1]==false){
n2.x+=2;
n2.y+=1;
flag[n2.x][n2.y]=true;
time[n2.x][n2.y]=n2.num;
q.push(n2);
n2.x-=2;
n2.y-=1;
}
if(n2.x-1>=0&&n2.x-1<=n&&n2.y+2>=0&&n2.y+2<=n&&flag[x-1][y+2]==false){
n2.x-=1;
n2.y+=2;
flag[n2.x][n2.y]=true;
time[n2.x][n2.y]=n2.num;
q.push(n2);
n2.x+=1;
n2.y-=2;
}
if(n2.x-2>=0&&n2.x-2<=n&&n2.y+1>=0&&n2.y+1<=n&&flag[x-2][y+1]==false){
n2.x-=2;
n2.y+=1;
flag[n2.x][n2.y]=true;
time[n2.x][n2.y]=n2.num;
q.push(n2);
n2.x+=2;
n2.y-=1;
}
if(n2.x+2>=0&&n2.x+2<=n&&n2.y-1>=0&&n2.y-1<=n&&flag[x+2][y-1]==false){
n2.x+=2;
n2.y-=1;
flag[n2.x][n2.y]=true;
time[n2.x][n2.y]=n2.num;
q.push(n2);
n2.x-=2;
n2.y+=1;
}
if(n2.x-1>=0&&n2.x-1<=n&&n2.y-2>=0&&n2.y-2<=n&&flag[x-1][y-2]==false){
n2.x-=1;
n2.y-=2;
flag[n2.x][n2.y]=true;
time[n2.x][n2.y]=n2.num;
q.push(n2);
n2.x+=1;
n2.y+=2;
}
if(n2.x-2>=0&&n2.x-2<=n&&n2.y-1>=0&&n2.y-1<=n&&flag[x-2][y-1]==false){
n2.x-=2;
n2.y-=1;
flag[n2.x][n2.y]=true;
time[n2.x][n2.y]=n2.num;
q.push(n2);
n2.x+=2;
n2.y+=1;
}
n2.num++;
}
for(int i=0;i<n;i++){
for(int j=0;j<m;j++){
cout<<time[i][j]<<" ";
}
cout<<endl;
}
return 0;
}