#include <bits/stdc++.h>
using namespace std;
char a[11][11];
int i, j, li, lj, s[5][5];
int main() {
  for (i = 0; i < 9; i++)
    for (j = 0; j < 9; j++) {
      cin >> a[i][j];
      if (a[i][j] == '.') s[i / 3][j / 3]++;
    }
  cin >> li >> lj;
  li--;
  lj--;
  lj %= 3;
  li %= 3;
  if (s[li][lj] > 0) {
    for (i = 0; i < 9; i++) {
      for (j = 0; j < 9; j++) {
        if (a[i][j] == '.' && i / 3 == li && j / 3 == lj)
          cout << "!";
        else
          cout << a[i][j];
        if (j == 2 || j == 5) cout << " ";
      }
      cout << "\n";
      if (i == 2 || i == 5) cout << "\n";
    }
  } else {
    for (i = 0; i < 9; i++) {
      for (j = 0; j < 9; j++) {
        if (a[i][j] == '.')
          cout << "!";
        else
          cout << a[i][j];
        if (j == 2 || j == 5) cout << " ";
      }
      cout << (i == 2 || i == 5 ? "\n\n" : "\n");
    }
  }
  return 0;
}
