#include<bits/stdc++.h>
using namespace std;
int n, m, x, y;
int mat[405][405];
int num = 0;
int xx[8] = { -1, -2, -2, -1, 1, 2, 2, 1 };
int yy[8] = { -2, -1, 1, 2, -2, -1, 1, 2 };
int cur = 1;
int cnt = 1;
struct node
{
int nx;
int ny;
}myqueue[405];
int main()
{
memset(mat, -1, sizeof(mat));
cin >> n >> m >> x >> y;
mat[x][y] = 0;
num++;
myqueue[num].nx = x;
myqueue[num].ny = y;
while (cnt != n * m)
{
int step = mat[myqueue[cur].nx][myqueue[cur].ny];
for (int ti = 0; ti < 8; ti++)
{
int newx = myqueue[cur].nx + xx[ti];
int newy = myqueue[cur].ny + yy[ti];
if (newx >= 1 && newx <= n && newy >= 1 && newy <= m && mat[newx][newy] == -1)
{
mat[newx][newy] = step + 1;
num++;
myqueue[num].nx = newx;
myqueue[num].ny = newy;
}
}
cur++;
cnt++;
}
for (int row = 1; row <= n; row++)
{
for (int col = 1; col <= m; col++)
cout << left << setw(5) << mat[row][col];
cout << '\n';
}
return 0;
}