#include <bits/stdc++.h>
using namespace std;
char a[12][12];
int x, y;
int x2, y2;
void Fill(int x1, int y1, int x2, int y2) {
  for (register int i = (x1); i <= (x2); ++i)
    for (register int j = (y1); j <= (y2); ++j)
      if (a[i][j] == '.') a[i][j] = '!';
}
int main() {
  for (register int i = (1); i <= (9); ++i)
    for (register int j = (1); j <= (9); ++j) cin >> a[i][j];
  cin >> x >> y;
  x2 = x % 3;
  x2 += (x2 == 0) * 3;
  y2 = y % 3;
  y2 += (y2 == 0) * 3;
  bool check = false;
  for (register int i = (x2 * 3 - 2); i <= (x2 * 3); ++i)
    for (register int j = (y2 * 3 - 2); j <= (y2 * 3); ++j)
      if (a[i][j] == '.') check = true;
  if (check)
    Fill(x2 * 3 - 2, y2 * 3 - 2, x2 * 3, y2 * 3);
  else
    Fill(1, 1, 9, 9);
  for (register int i = (1); i <= (9); ++i) {
    for (register int j = (1); j <= (9); ++j) {
      cout << a[i][j];
      if (j % 3 == 0) cout << ' ';
    }
    if (i % 3 == 0) cout << "\n";
    cout << endl;
  }
  return 0;
}
