#include <bits/stdc++.h>
using namespace std;
const int N=405;
int n,m,xx,yy;
int mx[8]={-2,-2,-1,-1,2,2,1,1};
int my[8]={1,-1,2,-2,1,-1,2,-2};
struct node{
int x;
int y;
int step;
}to;
queue<node> q;
void bfs(int i,int j){
bool vis[N][N]={false};
vis[xx][yy]=true;
q.push((node){xx,yy,0});
while(!q.empty()){
to=q.front();
q.pop();
if(to.x==i&&to.y==j)break;
for(int k=0;k<8;k++){
int temp=to.x+mx[k];
int temo=to.y+my[k];
if(temp>=1&&temp<=n&&temo>=1&&temo<=m&&!vis[temp][temo]){
vis[temp][temo]=true;
q.push((node){temp,temo,to.step+1});
cout<<to.step<<endl;
}
}
}
if(to.x==i&&to.y==j)cout<<to.step<<" ";
else cout<<"-1 ";
}
int main(){
cin>>n>>m>>xx>>yy;
for(int i=1;i<=n;i++){
for(int j=1;j<=m;j++){
bfs(i,j);
}
cout<<endl;
}
}