rt
#include <bits/stdc++.h>
using namespace std;
struct pos {
int x, y;
};
queue<pos> qu;
int mp[1000][1000];
int dx[] = {0, 0, 1, -1, 1, -1, 1, -1};
int dy[] = {1, -1, 0, 0, 1, 1, -1, -1};
int n, m;
void bfs() {
while (!qu.empty()) {
pos cur = qu.front();
qu.pop();
mp[cur.x][cur.y] = 2;
for (int i = 0; i < 8; i++) {
int nx = cur.x + dx[i], ny = cur.y + dy[i];
if (nx >= 0 && nx <= n && ny >= 0 && ny <= m) {
if (mp[nx][ny] == 0) {
mp[nx][ny] = 2;
} else if (mp[nx][ny] == 1) {
qu.push({nx, ny});
}
}
}
}
}
int main() {
cin >> n >> m;
for (int i = 1; i <= n; i++) {
for (int j = 1; j <= m; j++) {
cin >> mp[i][j];
}
}
int x, y;
cin >> x >> y;
if (mp[x][y] == 1) {
qu.push({x, y});
bfs();
}
for (int i = 1; i <= n; i++) {
for (int j = 1; j <= m; j++) {
cout << mp[i][j];
}
cout << endl;
}
return 0;
}