#include <bits/stdc++.h>
using namespace std;
char mp[11][11];
int main() {
  for (int i = 1; i <= 9; i++) {
    for (int j = 1; j <= 9; j++) {
      scanf(" %c", &mp[i][j]);
    }
  }
  int x, y;
  scanf("%d%d", &x, &y);
  x = (x - 1) % 3;
  y = (y - 1) % 3;
  int cnt = 0;
  for (int i = 3 * x + 1; i <= 3 * x + 3; i++) {
    for (int j = 3 * y + 1; j <= 3 * y + 3; j++) {
      if (mp[i][j] == '.') {
        ++cnt;
        mp[i][j] = '!';
      }
    }
  }
  if (cnt == 0) {
    for (int i = 1; i <= 9; i++) {
      for (int j = 1; j <= 9; j++) {
        if (mp[i][j] == '.') mp[i][j] = '!';
        printf("%c", mp[i][j]);
        if (j % 3 == 0) printf(" ");
      }
      puts("");
      if (i % 3 == 0) puts("");
    }
  } else {
    for (int i = 1; i <= 9; i++) {
      for (int j = 1; j <= 9; j++) {
        printf("%c", mp[i][j]);
        if (j % 3 == 0) printf(" ");
      }
      puts("");
      if (i % 3 == 0) puts("");
    }
  }
  return 0;
}
