#include <bits/stdc++.h>
using namespace std;
int n, m;
char board[15][15];
int main() {
  for (int by = 0; by < 3; by++) {
    for (int r = 0; r < 3; r++) {
      for (int bx = 0; bx < 3; bx++) {
        scanf("%s", &board[by * 3 + r][bx * 3]);
      }
    }
  }
  scanf("%d%d", &m, &n);
  int areaY = (m - 1) % 3, areaX = (n - 1) % 3;
  bool isfull = true;
  for (int y = 0; y < 3; y++) {
    for (int x = 0; x < 3; x++) {
      if (board[areaY * 3 + y][areaX * 3 + x] == '.') {
        isfull = false;
        goto check;
      }
    }
  }
check:
  if (isfull) {
    for (int y = 0; y < 9; y++) {
      for (int x = 0; x < 9; x++) {
        if (board[y][x] == '.') board[y][x] = '!';
      }
    }
  } else {
    for (int y = 0; y < 3; y++) {
      for (int x = 0; x < 3; x++) {
        if (board[areaY * 3 + y][areaX * 3 + x] == '.')
          board[areaY * 3 + y][areaX * 3 + x] = '!';
      }
    }
  }
printboard:
  for (int by = 0; by < 3; by++) {
    for (int r = 0; r < 3; r++) {
      printf("%c%c%c %c%c%c %c%c%c\n", board[by * 3 + r][0],
             board[by * 3 + r][1], board[by * 3 + r][2], board[by * 3 + r][3],
             board[by * 3 + r][4], board[by * 3 + r][5], board[by * 3 + r][6],
             board[by * 3 + r][7], board[by * 3 + r][8]);
    }
    putchar('\n');
  }
  return 0;
}
