#include <bits/stdc++.h>
using namespace std;
char str[15][15];
char com[10][10];
int x, y;
int ara[9][2] = {{0, 0}, {0, 3}, {0, 6}, {3, 0}, {3, 3},
                 {3, 6}, {6, 0}, {6, 3}, {6, 6}};
int main() {
  for (int i = 0; i < 11; i++) gets(str[i]);
  int row = -1, col = 0;
  for (int i = 0; i < 11; i++) {
    if (i == 3 || i == 7) continue;
    row++;
    col = 0;
    for (int j = 0; str[i][j]; j++) {
      if (str[i][j] == ' ') continue;
      com[row][col] = str[i][j];
      col++;
    }
  }
  scanf("%d %d", &x, &y);
  x--;
  y--;
  int sx, sy, dx, dy;
  for (int i = 0; i < 9; i++) {
    if (x >= ara[i][0] && x < (ara[i][0] + 3) && y >= ara[i][1] &&
        y < (ara[i][1] + 3)) {
      dx = x - ara[i][0];
      dy = y - ara[i][1];
    }
  }
  int nw[3][3] = {{0, 1, 2}, {3, 4, 5}, {6, 7, 8}};
  sx = ara[nw[dx][dy]][0];
  sy = ara[nw[dx][dy]][1];
  bool emp = false;
  for (int i = 0; i < 3; i++) {
    for (int j = 0; j < 3; j++) {
      if (com[sx + i][sy + j] == '.') emp = true;
    }
  }
  if (emp) {
    for (int i = 0; i < 3; i++) {
      for (int j = 0; j < 3; j++) {
        if (com[sx + i][sy + j] == '.') com[sx + i][sy + j] = '!';
      }
    }
  } else {
    for (int i = 0; i < 9; i++)
      for (int j = 0; j < 9; j++)
        if (com[i][j] == '.') com[i][j] = '!';
  }
  for (int i = 0; i < 9; i++) {
    if (i == 3 || i == 6) printf("\n");
    for (int j = 0; j < 9; j++) {
      if (j == 3 || j == 6) printf(" ");
      printf("%c", com[i][j]);
    }
    printf("\n");
  }
  return 0;
}
