#include <bits/stdc++.h>
using namespace std;
string s[12];
int x, y, r, c;
bool wolne;
int main() {
  for (int i = 0; i < 11; i++) {
    getline(cin, s[i]);
  }
  cin >> x >> y;
  r = (x - 1) % 3;
  c = (y - 1) % 3;
  wolne = false;
  for (int i = r * 4; i < r * 4 + 3; i++) {
    for (int j = c * 4; j < c * 4 + 3; j++) {
      if (s[i][j] == '.') wolne = true;
    }
  }
  if (wolne) {
    for (int i = r * 4; i < r * 4 + 3; i++) {
      for (int j = c * 4; j < c * 4 + 3; j++) {
        if (s[i][j] == '.') s[i][j] = '!';
      }
    }
  } else {
    for (int i = 0; i < 11; i++) {
      for (int j = 0; j < 11; j++) {
        if (s[i][j] == '.') s[i][j] = '!';
      }
    }
  }
  for (int i = 0; i < 11; i++) {
    cout << s[i] << "\n";
  }
}
