#include <bits/stdc++.h>
using namespace std;
const int maxn = 100 + 10;
char s[maxn][maxn];
int main() {
  int a, b;
  for (int i = 0; i < 11; i++) gets(s[i]);
  scanf("%d%d", &a, &b);
  int r = (a - 1) % 3, c = (b - 1) % 3;
  int flag = 0;
  for (int i = r * 3 + r; i < (r + 1) * 3 + r; i++) {
    for (int j = c * 3 + c; j < (c + 1) * 3 + c; j++) {
      if (s[i][j] == '.') {
        flag = 1;
        break;
      }
    }
  }
  if (flag) {
    for (int i = r * 3 + r; i < (r + 1) * 3 + r; i++) {
      for (int j = c * 4; j < c * 4 + 3; j++) {
        if (s[i][j] == '.') s[i][j] = '!';
      }
    }
    for (int i = 0; i < 11; i++) printf("%s\n", s[i]);
  } else {
    for (int i = 0; i < 11; i++) {
      for (int j = 0; j < 11; j++)
        if (s[i][j] == '.') s[i][j] = '!';
    }
    for (int i = 0; i < 11; i++) printf("%s\n", s[i]);
  }
  return 0;
}
