#include <bits/stdc++.h>
using namespace std;
int main() {
  vector<string> grid(10);
  int o = 0;
  for (int i = 0; i < (11); i++) {
    string s;
    getline(cin, s);
    int j = 0;
    while (s[j]) {
      s[j] = s[j + j / 3];
      j++;
    }
    if (s.length()) {
      s.resize(9);
      grid[o] = s;
      o++;
    }
  }
  int x, y;
  cin >> x >> y;
  x--;
  y--;
  int fX = x % 3;
  int fY = y % 3;
  fX *= 3;
  fY *= 3;
  bool good = 0;
  for (int i = 0; i < (grid.size()); i++) {
    for (int o = 0; grid[i][o]; o++) {
      if (i >= fX && i <= fX + 2 && o >= fY && o <= fY + 2) {
        if (grid[i][o] == '.') {
          good = 1;
          grid[i][o] = '!';
        }
      }
    }
  }
  if (good) {
    for (int i = 0; i < (grid.size()); i++) {
      for (int j = 0; grid[i][j]; j++) {
        if (j && j % 3 == 0) cout << " ";
        cout << grid[i][j];
      }
      cout << "\n";
      if ((i + 1) % 3 == 0) cout << '\n';
    }
    return 0;
  }
  for (int i = 0; i < (grid.size()); i++) {
    for (int o = 0; grid[i][o]; o++) {
      if (grid[i][o] == '.') {
        good = 1;
        grid[i][o] = '!';
      }
    }
    for (int j = 0; grid[i][j]; j++) {
      if (j && j % 3 == 0) cout << " ";
      cout << grid[i][j];
    }
    cout << "\n";
    if ((i + 1) % 3 == 0) cout << '\n';
  }
  return 0;
}
