#include <bits/stdc++.h>
using namespace std;
char s[15][15];
int jg(int x, int y) {
  x %= 3;
  if (!x) x = 3;
  y %= 3;
  if (!y) y = 3;
  if (x == 1 && y == 1) return 1;
  if (x == 1 && y == 2) return 2;
  if (x == 1 && y == 3) return 3;
  if (x == 2 && y == 1) return 4;
  if (x == 2 && y == 2) return 5;
  if (x == 2 && y == 3) return 6;
  if (x == 3 && y == 1) return 7;
  if (x == 3 && y == 2) return 8;
  if (x == 3 && y == 3) return 9;
}
void wowo(int x, int y) {
  bool flag = 1;
  for (int i = 1; i <= 3; ++i)
    for (int j = 1; j <= 3; ++j) {
      if (s[x + i][y + j] == '.') {
        flag = 0;
        s[x + i][y + j] = '!';
      }
    }
  if (flag) {
    for (int i = 1; i <= 9; ++i)
      for (int j = 1; j <= 9; ++j) {
        if (s[i][j] == '.') s[i][j] = '!';
      }
  }
}
void solvee(int tmp) {
  if (tmp == 1) wowo(0, 0);
  if (tmp == 2) wowo(0, 3);
  if (tmp == 3) wowo(0, 6);
  if (tmp == 4) wowo(3, 0);
  if (tmp == 5) wowo(3, 3);
  if (tmp == 6) wowo(3, 6);
  if (tmp == 7) wowo(6, 0);
  if (tmp == 8) wowo(6, 3);
  if (tmp == 9) wowo(6, 6);
}
int main() {
  for (int i = 1; i <= 9; ++i) {
    scanf("%s", s[i] + 1);
    scanf("%s", s[i] + 4);
    scanf("%s", s[i] + 7);
  }
  int x, y;
  scanf("%d %d", &x, &y);
  int tmp = jg(x, y);
  solvee(tmp);
  fflush(stdin);
  for (int i = 1; i <= 9; ++i) {
    for (int j = 1; j <= 9; ++j) {
      printf("%c", s[i][j]);
      if (j % 3 == 0 && j != 9) printf(" ");
    }
    printf("\n");
    if (i % 3 == 0 && i != 9) printf("\n");
  }
  return 0;
}
