#include <bits/stdc++.h>
using namespace std;
const int N = 30;
char s[N][N];
int main() {
  for (int i = 0, iend = (8) + 1; i < iend; ++i) {
    for (int j = 0, jend = (2) + 1; j < jend; ++j) scanf("%s", s[i] + j * 3);
  }
  int x, y, ok = 0;
  scanf("%d%d", &x, &y);
  --x, --y;
  for (int i = (x % 3) * 3, iend = ((x % 3) * 3 + 2) + 1; i < iend; ++i)
    for (int j = (y % 3) * 3, jend = ((y % 3) * 3 + 2) + 1; j < jend; ++j)
      if (s[i][j] == '.') s[i][j] = '!', ok = 1;
  if (!ok)
    for (int i = 0, iend = (8) + 1; i < iend; ++i)
      for (int j = 0, jend = (9) + 1; j < jend; ++j)
        if (s[i][j] == '.') s[i][j] = '!';
  for (int i = 0, iend = (8) + 1; i < iend; ++i) {
    for (int j = 0, jend = (2) + 1; j < jend; ++j)
      printf("%c%c%c ", s[i][j * 3], s[i][j * 3 + 1], s[i][j * 3 + 2]);
    puts(i % 3 == 2 ? "\n" : "");
  }
  return 0;
}
