#include <bits/stdc++.h>
using namespace std;
int n, m;
char s[15][15];
inline int read() {
  int x = 0, f = 1;
  char ch = getchar();
  for (; ch < '0' || ch > '9'; ch = getchar())
    if (ch == '-') f = -1;
  for (; ch >= '0' && ch <= '9'; ch = getchar()) x = x * 10 + ch - '0';
  return x * f;
}
int main() {
  for (int i = 0; i < 11; i++) gets(s[i]);
  int x = (read() - 1) % 3 + 1, y = (read() - 1) % 3 + 1;
  if (x == 1) x = 0;
  if (x == 2) x = 4;
  if (x == 3) x = 8;
  if (y == 1) y = 0;
  if (y == 2) y = 4;
  if (y == 3) y = 8;
  bool flag = 0;
  for (int i = 0; i < 3; i++)
    for (int j = 0; j < 3; j++)
      if (s[x + i][y + j] == '.') flag = 1;
  if (flag) {
    for (int i = 0; i < 3; i++)
      for (int j = 0; j < 3; j++)
        if (s[x + i][y + j] == '.') s[x + i][y + j] = '!';
  } 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++) cout << s[i] << endl;
  return 0;
}
