#include <bits/stdc++.h>
using namespace std;
using lli = long long;
using Double = long double;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  string s[9][3];
  for (int i = 0; i < 9; ++i) {
    for (int j = 0; j < 3; ++j) {
      cin >> s[i][j];
    }
  }
  int x, y, cnt = 0;
  cin >> x >> y, --x, --y;
  for (auto c : s[x % 3 * 3][y % 3]) cnt += c == '.';
  for (auto c : s[x % 3 * 3 + 1][y % 3]) cnt += c == '.';
  for (auto c : s[x % 3 * 3 + 2][y % 3]) cnt += c == '.';
  if (cnt == 0) {
    for (int i = 0; i < 9; ++i) {
      for (int j = 0; j < 3; ++j) {
        for (auto c : s[i][j]) {
          cout << (c == '.' ? '!' : c);
        }
        cout << " \n"[j == 2];
      }
      if (i % 3 == 2) cout << "\n";
    }
  } else {
    for (int i = 0; i < 9; ++i) {
      for (int j = 0; j < 3; ++j) {
        for (auto c : s[i][j]) {
          cout << (c == '.' and i / 3 == x % 3 and j == y % 3 ? '!' : c);
        }
        cout << " \n"[j == 2];
      }
      if (i % 3 == 2) cout << "\n";
    }
  }
  return 0;
}
