#include<bits/stdc++.h>
using namespace std;
int mp[500][500];
int vis[500][500];
/*
. + . + .
+ . . . +
. . - . .
+ . . . +
. + . + .
*/
int tx[8] = {1,2,-1,-2,-1,-2, 1, 2};
int ty[8] = {2,1, 2, 1,-2,-1,-2,-1};
queue <int> qx;
queue <int> qy;
int n,m,sx,sy;
int main()
{
cin >> n >> m >> sx >> sy;
qx.push(sx);
qy.push(sy);
int cnt = 0;
for(int i = 1;i<=n;i++)
{
for(int j = 1;j<=m;j++)
{
mp[i][j] = INT_MAX;
}
}
mp[sx][sy] = 0;
vis[sx][sy] = 1;
while(qx.empty() == 0 && qy.empty() == 0)
{
int x = qx.front();int y = qy.front();
qx.pop();qy.pop();
cnt++;
for(int i = 0;i<8;i++)
{
int nx = x + tx[i];int ny = y + ty[i];
if(nx >= 1 && ny >= 1 && nx <= n && ny <= m && vis[nx][ny] == 0)
{
if(mp[nx][ny] <= cnt)
{
continue;
}
mp[nx][ny] = cnt;
qx.push(nx);
qy.push(ny);
}
}
}
for(int i = 1;i<=n;i++)
{
for(int j = 1;j<=m;j++)
{
if(mp[i][j] != INT_MAX)
{
cout << mp[i][j] << " ";
}
else
{
cout << -1 << " ";
}
}
cout << '\n';
}
return 0;
}
995