#include <bits/stdc++.h>
using namespace std;
int main() {
  char a[10][10];
  int x, y, i, j;
  for (i = 1; i <= 9; i++) {
    for (j = 1; j <= 9; j++) {
      cin >> a[i][j];
    }
  }
  cin >> x >> y;
  if (x % 3 == 0)
    x = 7;
  else if (x % 3 == 2)
    x = 4;
  else
    x = 1;
  if (y % 3 == 0)
    y = 7;
  else if (y % 3 == 2)
    y = 4;
  else
    y = 1;
  i = 0, j = 0;
  int flag = 0;
  for (i = 0; i < 3; i++) {
    for (j = 0; j < 3; j++) {
      if (a[x + i][y + j] == '.') {
        flag = 1;
      }
    }
  }
  if (flag) {
    for (i = 1; i <= 9; i++) {
      for (j = 1; j <= 9; j++) {
        if (i >= x && i < x + 3 && j >= y && j < y + 3 && a[i][j] == '.')
          cout << "!";
        else
          cout << a[i][j];
        if (j % 3 == 0) cout << " ";
      }
      cout << "\n";
      if (i % 3 == 0) cout << "\n";
    }
  } else {
    for (i = 1; i <= 9; i++) {
      for (j = 1; j <= 9; j++) {
        if (a[i][j] == '.')
          cout << "!";
        else
          cout << a[i][j];
        if (j % 3 == 0) cout << " ";
      }
      cout << "\n";
      if (i % 3 == 0) cout << "\n";
    }
  }
  return 0;
}
