const rl = require("readline").createInterface({ input: process.stdin });
var iter = rl[Symbol.asyncIterator]();
const readline = async () => (await iter.next()).value;
void (async function () {
const [len, tate] = (await readline()).split(" ").map(Number);
let arr = (await readline()).split(" ").map(Number);
const matrix = [];
const [i, j] = (await readline()).split(" ").map(Number);
while (arr.length > 0) {
const slice = arr.splice(0, tate);
matrix.push(slice);
}
const start = [];
for (let i = 0; i < len; i++) {
for (let j = 0; j < tate; j++) {
if (matrix[i][j] > 0) start.push([i, j]);
}
}
const offset = [
[-1, 0],
[1, 0],
[0, -1],
[0, 1],
];
let ans = 0;
const bfs = (x, y) => {
const queue = [];
queue.push([x, y]);
while (queue.length > 0) {
const [x, y] = queue.shift();
for (const [offsetX, offsetY] of offset) {
const newX = x + offsetX;
const newY = y + offsetY;
if (
newX >= 0 &&
newX < len &&
newY >= 0 &&
newY < tate &&
matrix[newX][newY] < matrix[x][y] - 1
) {
matrix[newX][newY] = matrix[x][y] - 1;
if (matrix[newX][newY] + 0) queue.push([newX, newY]);
}
}
}
};
for (let [x, y] of start) {
bfs(x, y);
ans = Math.max(ans, matrix[i][j]);
}
console.log(ans, matrix);
})();