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