#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(NULL);
  char a[9][9], c;
  int i, j, x, y;
  string s;
  for (i = 0; i < 9; i++) {
    for (j = 0; j < 3; j++) {
      cin >> s;
      a[i][3 * j] = s[0];
      a[i][3 * j + 1] = s[1];
      a[i][3 * j + 2] = s[2];
    }
  }
  cin >> x >> y;
  x--;
  y--;
  x %= 3;
  y %= 3;
  bool b = 0;
  for (i = 0; i < 3; i++) {
    for (j = 0; j < 3; j++) {
      if (a[3 * x + i][3 * y + j] == '.') b = 1;
    }
  }
  if (b) {
    for (i = 0; i < 9; i++) {
      if (i % 3 == 0 && i != 0) cout << '\n';
      for (j = 0; j < 9; j++) {
        if (j % 3 == 0 && j != 0) cout << " ";
        if (x != i / 3 || y != j / 3)
          cout << a[i][j];
        else {
          if (a[i][j] == '.')
            cout << "!";
          else
            cout << a[i][j];
        }
      }
      cout << '\n';
    }
  } else {
    for (i = 0; i < 9; i++) {
      if (i % 3 == 0 && i != 0) cout << '\n';
      for (j = 0; j < 9; j++) {
        if (j % 3 == 0 && j != 0) cout << " ";
        if (a[i][j] == '.')
          cout << "!";
        else
          cout << a[i][j];
      }
      cout << '\n';
    }
  }
}
