#include <bits/stdc++.h>
using namespace std;
char s[15][15];
int main() {
  int i, j;
  int x, y;
  bool flag = 0;
  for (i = 1; i <= 9; i++) {
    for (j = 1; j <= 9; j++) {
      do s[i][j] = getchar();
      while (s[i][j] <= 32);
    }
  }
  scanf("%d %d", &x, &y);
  x = (x - 1) % 3 + 1;
  y = (y - 1) % 3 + 1;
  for (i = (x - 1) * 3 + 1; i <= x * 3; i++)
    for (j = (y - 1) * 3 + 1; j <= y * 3; j++)
      if (s[i][j] == '.') {
        s[i][j] = '!';
        flag = 1;
      }
  if (!flag) {
    for (i = 1; i <= 9; i++)
      for (j = 1; j <= 9; j++)
        if (s[i][j] == '.') s[i][j] = '!';
  }
  for (i = 1; i <= 9; i++) {
    for (j = 1; j <= 9; j++) {
      putchar(s[i][j]);
      if (!(j % 3)) putchar(' ');
    }
    putchar('\n');
    if (!(i % 3)) putchar('\n');
  }
  return 0;
}
