#include <bits/stdc++.h>
using namespace std;
char a[10][10];
int main() {
  int i, j, count1 = 0;
  bool t = false;
  for (int k = 0; k < 9; k++)
    for (int l = 0; l < 9; l++) cin >> a[k][l];
  cin >> i >> j;
  if (i == 3 || i == 6 || i == 9)
    i = 3;
  else if (i == 2 || i == 5 || i == 8)
    i = 2;
  else
    i = 1;
  if (j == 3 || j == 6 || j == 9)
    j = 3;
  else if (j == 2 || j == 5 || j == 8)
    j = 2;
  else
    j = 1;
  for (int k = (i - 1) * 3; k < i * 3; k++)
    for (int l = (j - 1) * 3; l < j * 3; l++)
      if (a[k][l] == '.') {
        t = true;
      }
  if (t == true) {
    for (int k = 0; k < 9; k++) {
      if (k == 3 || k == 6) cout << endl;
      for (int l = 0; l < 9; l++) {
        if (l == 3 || l == 6) cout << ' ';
        if (k >= (i - 1) * 3 && k < i * 3 && l >= (j - 1) * 3 && l < j * 3) {
          if (a[k][l] == '.')
            cout << '!';
          else
            cout << a[k][l];
        } else
          cout << a[k][l];
      }
      cout << endl;
    }
  } else {
    for (int k = 0; k < 9; k++) {
      if (k == 3 || k == 6) cout << endl;
      for (int l = 0; l < 9; l++) {
        if (l == 3 || l == 6) cout << ' ';
        if (a[k][l] == '.')
          cout << '!';
        else
          cout << a[k][l];
      }
      cout << endl;
    }
  }
  return 0;
}
