#include <bits/stdc++.h>
using namespace std;
char s[15][15];
int a[5][5];
int main() {
  memset(a, 0, sizeof(a));
  memset(s, '0', sizeof(s));
  int tx, ty, x, y, k = 1, kk = 1;
  for (int i = 0; i < 11; i++) {
    if (i == 3 || i == 7)
      getchar();
    else {
      for (int j = 0; j < 11; j++) {
        if (j == 3 || j == 7)
          getchar();
        else
          scanf("%c", &s[k][kk++]);
      }
      getchar();
      k++, kk = 1;
    }
  }
  for (int i = 1; i < 10; i++) {
    for (int j = 1; j < 10; j++) {
      if (s[i][j] != '.') {
        if (i % 3)
          tx = i / 3 + 1;
        else
          tx = i / 3;
        if (j % 3)
          ty = j / 3 + 1;
        else
          ty = j / 3;
        a[tx][ty]++;
      }
    }
  }
  scanf("%d%d", &x, &y);
  tx = x % 3, ty = y % 3;
  if (!tx)
    x = 3;
  else
    x = tx;
  if (!ty)
    y = 3;
  else
    y = ty;
  if (a[x][y] != 9) {
    for (int i = 1; i < 10; i++) {
      for (int j = 1; j < 10; j++) {
        if (j == 4 || j == 7) printf(" ");
        if (i > (x - 1) * 3 && i <= x * 3 && j > (y - 1) * 3 && j <= y * 3 &&
            s[i][j] == '.')
          printf("!");
        else
          printf("%c", s[i][j]);
      }
      if (i == 3 || i == 6) printf("\n");
      printf("\n");
    }
  } else {
    for (int i = 1; i < 10; i++) {
      for (int j = 1; j < 10; j++) {
        if (j == 4 || j == 7) printf(" ");
        if (s[i][j] != '.')
          printf("%c", s[i][j]);
        else
          printf("!");
      }
      if (i == 3 || i == 6) printf("\n");
      printf("\n");
    }
  }
}
