#include <bits/stdc++.h>
using namespace std;
class Node {
 public:
  char str[5][5];
  bool Fill() {
    for (int i = 1; i <= 3; ++i) {
      for (int j = 0; j < 3; ++j) {
        if (str[i][j] == '.') return false;
      }
    }
    return true;
  }
  void Change() {
    for (int i = 1; i <= 3; ++i) {
      for (int j = 0; j < 3; ++j) {
        if (str[i][j] == '.') str[i][j] = '!';
      }
    }
  }
};
Node q[15];
int X, Y;
void input() {
  for (int i = 1; i <= 3; ++i) {
    scanf("%s %s %s", q[1].str[i], q[2].str[i], q[3].str[i]);
  }
  getchar();
  for (int i = 1; i <= 3; ++i) {
    scanf("%s %s %s", q[4].str[i], q[5].str[i], q[6].str[i]);
  }
  getchar();
  for (int i = 1; i <= 3; ++i) {
    scanf("%s %s %s", q[7].str[i], q[8].str[i], q[9].str[i]);
  }
  scanf("%d %d", &X, &Y);
}
int Getpos(int xx, int yy) {
  if (xx == 1 && yy == 1) return 1;
  if (xx == 1 && yy == 2) return 2;
  if (xx == 1 && yy == 0) return 3;
  if (xx == 2 && yy == 1) return 4;
  if (xx == 2 && yy == 2) return 5;
  if (xx == 2 && yy == 0) return 6;
  if (xx == 0 && yy == 1) return 7;
  if (xx == 0 && yy == 2) return 8;
  if (xx == 0 && yy == 0) return 9;
  return 0;
}
void output() {
  for (int i = 1; i <= 3; ++i) {
    printf("%s %s %s\n", q[1].str[i], q[2].str[i], q[3].str[i]);
  }
  printf("\n");
  for (int i = 1; i <= 3; ++i) {
    printf("%s %s %s\n", q[4].str[i], q[5].str[i], q[6].str[i]);
  }
  printf("\n");
  for (int i = 1; i <= 3; ++i) {
    printf("%s %s %s\n", q[7].str[i], q[8].str[i], q[9].str[i]);
  }
}
void solve() {
  X %= 3;
  Y %= 3;
  int pos = Getpos(X, Y);
  if (q[pos].Fill()) {
    for (int i = 1; i <= 9; ++i) {
      q[i].Change();
    }
  } else {
    q[pos].Change();
  }
}
int main(void) {
  input();
  solve();
  output();
  return 0;
}
