#include <bits/stdc++.h>
using namespace std;
void mygetline(string &name) {
  getline(cin, name);
  stringstream myStream(name);
}
int main() {
  ios::sync_with_stdio(false);
  string s[10], t;
  for (int i = 0; i < 3; i++) mygetline(s[i]);
  mygetline(t);
  for (int i = 3; i < 6; i++) mygetline(s[i]);
  mygetline(t);
  for (int i = 6; i < 9; i++) mygetline(s[i]);
  int x, y;
  cin >> x >> y;
  x--, y--;
  int ix = x % 3;
  int iy = y % 3;
  bool flag = true;
  for (int i = ix * 3; i < ix * 3 + 3; i++)
    for (int j = iy * 4; j < iy * 4 + 3; j++)
      if (s[i][j] == '.') {
        s[i][j] = '!';
        flag = false;
      }
  if (flag)
    for (int i = 0; i < 9; i++)
      for (int j = 0; j < s[i].size(); j++)
        if (s[i][j] == '.') s[i][j] = '!';
  for (int i = 0; i < 3; i++) cout << s[i] << endl;
  cout << endl;
  for (int i = 3; i < 6; i++) cout << s[i] << endl;
  cout << endl;
  for (int i = 6; i < 9; i++) cout << s[i] << endl;
  return 0;
}
