#include <bits/stdc++.h>
using namespace std;
string s[20];
int main() {
  int i, j;
  for (i = 0; i < 11; i++) getline(cin, s[i]);
  int x, y;
  scanf("%d %d", &x, &y);
  x--;
  y--;
  int xx = x - (x / 3) * 3;
  int yy = y - (y / 3) * 3;
  int sr = 3 * xx;
  int er = 3 * (xx + 1) - 1;
  int sc = 3 * yy;
  int ec = 3 * (yy + 1) - 1;
  sr += xx;
  er += xx;
  sc += yy;
  ec += yy;
  int f = 0;
  for (i = sr; i <= er; i++) {
    for (j = sc; j <= ec; j++) {
      if (s[i][j] == '.') {
        s[i][j] = '!';
        f = 1;
      }
    }
  }
  if (f) {
    for (i = 0; i < 11; i++) cout << s[i] << endl;
  } else {
    for (i = 0; i < 11; i++)
      for (j = 0; j < 11; j++) {
        if (i >= sr && i <= er && j >= sc && j <= ec)
          continue;
        else {
          if (s[i][j] == '.') s[i][j] = '!';
        }
      }
    for (i = 0; i < 11; i++) cout << s[i] << endl;
  }
  return 0;
}
