#include <bits/stdc++.h>
using namespace std;
const long long inf = 1e18;
const long long maxn = 2e5 + 10;
int main() {
  string s[12];
  for (long long i = 0; i < 11; i++) {
    getline(cin, s[i]);
  }
  long long a, b;
  cin >> a >> b;
  long long x = a % 3, y = b % 3;
  x = ((x == 0) ? 3 : x);
  y = ((y == 0) ? 3 : y);
  x = (x - 1) * 4 + 1;
  y = (y - 1) * 4 + 1;
  bool emp = 0;
  for (long long i = 0; i < 3; i++) {
    for (long long j = 0; j < 3; j++) {
      if (s[x + i - 1][y + j - 1] == '.') {
        emp = 1;
        s[x + i - 1][y + j - 1] = '!';
      }
    }
  }
  if (!emp) {
    for (long long i = 0; i < 11; i++) {
      for (long long j = 0; j < (s[i]).size(); j++) {
        if (s[i][j] == '.') {
          s[i][j] = '!';
        }
      }
    }
  }
  for (long long i = 0; i < 11; i++) {
    cout << s[i] << endl;
  }
}
