#include <bits/stdc++.h>
using namespace std;
int main() {
  vector<string> v(9);
  for (int i = 0; i < 9; ++i) {
    string s;
    for (int j = 0; j < 3; ++j) {
      cin >> s;
      v[i] += s;
    }
  }
  int y, x;
  cin >> y >> x;
  bool ok = false;
  for (int i = 0; i < 3; ++i) {
    for (int j = 0; j < 3; ++j) {
      int y0 = ((y - 1) % 3) * 3 + i;
      int x0 = ((x - 1) % 3) * 3 + j;
      if (v[y0][x0] == '.') {
        ok = true;
        v[y0][x0] = '!';
      }
    }
  }
  if (!ok) {
    for (int i = 0; i < 9; ++i)
      for (int j = 0; j < 9; ++j)
        if (v[i][j] == '.') v[i][j] = '!';
  }
  for (int i = 0; i < 3; ++i) {
    if (i > 0) cout << endl;
    for (int j = 0; j < 3; ++j) {
      cout << v[i * 3 + j].substr(0, 3) << ' ' << v[i * 3 + j].substr(3, 3)
           << ' ' << v[i * 3 + j].substr(6, 3) << endl;
    }
  }
  return 0;
}
