#include <bits/stdc++.h>
using namespace std;
int read() {
  int xx = 0, ff = 1;
  char ch = getchar();
  while (ch > '9' || ch < '0') {
    if (ch == '-') ff = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    xx = (xx << 3) + (xx << 1) + ch - '0';
    ch = getchar();
  }
  return xx * ff;
}
char mp[10][10];
int n, m;
void myfill(int sx, int fx, int sy, int fy) {
  for (int i = sx; i <= fx; i++)
    for (int j = sy; j <= fy; j++)
      if (mp[i][j] == '.') mp[i][j] = '!';
}
bool rep(int sx, int fx, int sy, int fy) {
  for (int i = sx; i <= fx; i++)
    for (int j = sy; j <= fy; j++)
      if (mp[i][j] == '.') {
        myfill(sx, fx, sy, fy);
        return 1;
      }
  return 0;
}
int main() {
  for (int i = 1; i <= 9; i++)
    for (int j = 1; j <= 9; j++) {
      mp[i][j] = getchar();
      while (mp[i][j] == 10 || mp[i][j] == 32) mp[i][j] = getchar();
    }
  n = read(), m = read();
  bool flag;
  if (n % 3 == 1) {
    if (m % 3 == 1)
      flag = rep(1, 3, 1, 3);
    else if (m % 3 == 2)
      flag = rep(1, 3, 4, 6);
    else
      flag = rep(1, 3, 7, 9);
  } else if (n % 3 == 2) {
    if (m % 3 == 1)
      flag = rep(4, 6, 1, 3);
    else if (m % 3 == 2)
      flag = rep(4, 6, 4, 6);
    else
      flag = rep(4, 6, 7, 9);
  } else {
    if (m % 3 == 1)
      flag = rep(7, 9, 1, 3);
    else if (m % 3 == 2)
      flag = rep(7, 9, 4, 6);
    else
      flag = rep(7, 9, 7, 9);
  }
  if (!flag) myfill(1, 9, 1, 9);
  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;
}
