#include <bits/stdc++.h>
using namespace std;
char m[3][3][3][5];
int main() {
  int cnt0 = 0, cnt1 = 0;
  for (int i = 0; i < 3; ++i)
    for (int j = 0; j < 3; ++j)
      for (int k = 0; k < 3; ++k) {
        scanf("%s", m[i][k][j]);
      }
  int x, y;
  scanf("%d %d", &x, &y);
  x = (x - 1) % 3;
  y = (y - 1) % 3;
  int cnt = 0;
  for (int i = 0; i < 3; ++i)
    for (int j = 0; j < 3; ++j)
      if (m[x][y][i][j] == '.') {
        m[x][y][i][j] = '!';
        cnt++;
      }
  if (!cnt) {
    for (int i = 0; i < 3; ++i)
      for (int j = 0; j < 3; ++j)
        for (int k = 0; k < 3; ++k)
          for (int s = 0; s < 3; ++s)
            if (m[i][j][k][s] == '.') m[i][j][k][s] = '!';
  }
  for (int i = 0; i < 3; ++i) {
    for (int j = 0; j < 3; ++j) {
      for (int k = 0; k < 3; ++k) printf("%s ", m[i][k][j]);
      printf("\n");
    }
    printf("\n");
  }
  return 0;
}
