#include <bits/stdc++.h>
using namespace std;
char a[222][222];
char b[222][222];
int main() {
  for (int i = 1; i <= 9; i++) {
    scanf("%s", a[i] + 1);
    scanf("%s", a[i] + 4);
    scanf("%s", a[i] + 7);
    int k = 1;
    for (int j = 1; j <= 9; j++) {
      b[i][j] = a[i][j];
    }
  }
  int x, y;
  cin >> x >> y;
  while (x > 3) x -= 3;
  while (y > 3) y -= 3;
  if (x == 2 && y == 2) {
    for (int i = 1; i <= 9; i++) {
      for (int j = 1; j <= 9; j++) {
        if (b[i][j] == '.') b[i][j] = '!';
      }
    }
    for (int i = 1; i <= 9; i++) {
      for (int j = 1; j <= 9; j++) {
        printf("%c", b[i][j]);
        if (j == 3 || j == 6) printf(" ");
      }
      if (i == 3 || i == 6) printf("\n");
      printf("\n");
    }
    return 0;
  }
  int p = (x - 1) * 3 + 1;
  int q = (y - 1) * 3 + 1;
  int cnt = 0;
  for (int i = p; i <= p + 2; i++) {
    for (int j = q; j <= q + 2; j++) {
      if (b[i][j] == '.') cnt++;
    }
  }
  if (cnt)
    for (int i = p; i <= p + 2; i++) {
      for (int j = q; j <= q + 2; j++) {
        if (b[i][j] == '.') b[i][j] = '!';
      }
    }
  else {
    for (int i = 1; i <= 9; i++) {
      for (int j = 1; j <= 9; j++) {
        if (b[i][j] == '.') b[i][j] = '!';
      }
    }
  }
  for (int i = 1; i <= 9; i++) {
    for (int j = 1; j <= 9; j++) {
      printf("%c", b[i][j]);
      if (j == 3 || j == 6) printf(" ");
    }
    if (i == 3 || i == 6) printf("\n");
    printf("\n");
  }
  return 0;
}
