#include<bits/stdc++.h>
using namespace std;
int dir[8][2]={{1,2},{1,-2},{-1,2},{-1,-2},{2,1},{2,-1},{-2,1},{-2,-1}};
struct aa{
int x,y;
};
int ans[454][454];
queue<aa> q;
int n;
int m;
int x;
int y;
int mian(){
cin>>n>>m>>x>>y;
aa xx={x,y};
q.push(xx);
memset (ans,-1,sizeof(ans));
ans[x][y]=0;
while(!q.empty()){
aa topp=q.front();
q.pop();
int ax=topp.x;
int ay=topp.y;
for(int i=0;i<8;++i){
int bx=ax+dir[i][0];
int by=ay+dir[i][0];
if(by>m||ans[bx][by]!=-1||by<1||bx<1||bx>n){
continue;
}
ans[bx][by]=ans[ax][ay]+1;
aa cur={bx,by};
q.push(cur);
}
}
for(int i=1;i<=n;++i){
for(int j=1;j<=m;++j){
cout<<ans[i][j]<<" ";
}
cout<<endl;
}
return 0;
}