#include <bits/stdc++.h>
using namespace std;
char a[9][9];
int main() {
  for (int i = 0; i < 9; ++i)
    for (int j = 0; j < 9; ++j) cin >> a[i][j];
  int x, y;
  cin >> x >> y;
  x--;
  y--;
  x = 3 * (x % 3), y = 3 * (y % 3);
  bool flag = false;
  for (int i = 0; i < 9; ++i) {
    if (a[x + i / 3][y + i % 3] == '.') {
      flag = true;
      a[x + i / 3][y + i % 3] = '!';
    }
  }
  if (!flag) {
    for (int i = 0; i < 9; ++i)
      for (int j = 0; j < 9; ++j)
        if (a[i][j] == '.') a[i][j] = '!';
  }
  for (int i = 0; i < 9; ++i) {
    for (int j = 0; j < 9; ++j) {
      cout << a[i][j];
      if (j % 3 == 2) cout << " ";
    }
    cout << "\n";
    if (i % 3 == 2) cout << "\n";
  }
}
