#include <bits/stdc++.h>
using namespace std;
const int N = 1e3 + 10;
const long long MAXN = 9e18 + 10;
const int MAX = 1e2 + 10;
const long long mod = 1e9 + 7;
char o[15][15];
void solve() {
  int temp = 1, x, y;
  for (int i = 1; i < 10; ++i) {
    int cnt = 1;
    for (int j = 1; j < 10; ++j) {
      o[i][j] = getchar();
      if (cnt % 3 == 0) getchar();
      cnt++;
    }
    if (temp % 3 == 0 && temp != 9) getchar();
    temp++;
  }
  scanf("%d", &x);
  scanf("%d", &y);
  x = (x - 1) % 3 + 1;
  y = (y - 1) % 3 + 1;
  bool flag = false;
  for (int i = 3 * (x - 1) + 1; i < 3 * x + 1; ++i) {
    for (int j = 3 * (y - 1) + 1; j < 3 * y + 1; ++j) {
      if (o[i][j] == '.') {
        flag = true;
        o[i][j] = '!';
      }
    }
  }
  if (!flag) {
    for (int i = 1; i < 10; ++i) {
      for (int j = 1; j < 10; ++j) {
        if (o[i][j] == '.') o[i][j] = '!';
      }
    }
  }
  temp = 1;
  for (int i = 1; i < 10; ++i) {
    int cnt = 1;
    for (int j = 1; j < 10; ++j) {
      printf("%c", o[i][j]);
      if (cnt % 3 == 0 && cnt != 9) printf(" ");
      cnt++;
    }
    printf("\n");
    if (temp % 3 == 0 && temp != 9) printf("\n");
    temp++;
  }
  return;
}
int main() {
  int casen = 1;
  while (casen--) {
    solve();
  }
  return 0;
}
