#include <bits/stdc++.h>
struct Square {
  char points[4][4];
  int used;
};
Square square[4][4];
void calcSquare(int x, int y) {
  square[x][y].used = 0;
  for (int x1 = 1; x1 <= 3; x1++) {
    for (int y1 = 1; y1 <= 3; y1++) {
      if (square[x][y].points[x1][y1] == 'x') square[x][y].used++;
      if (square[x][y].points[x1][y1] == 'o') square[x][y].used++;
    }
  }
}
void paint(int x, int y) {
  for (int x1 = 1; x1 <= 3; x1++) {
    for (int y1 = 1; y1 <= 3; y1++) {
      if (square[x][y].points[x1][y1] == '.') square[x][y].points[x1][y1] = '!';
    }
  }
}
void checkNextPoint(int px, int py) {
  int sx, sy;
  sx = (px - 1) / 3;
  sy = (py - 1) / 3;
  int ssx, ssy;
  ssx = px - sx * 3;
  ssy = py - sy * 3;
  if (square[ssx][ssy].used < 9) {
    paint(ssx, ssy);
  } else {
    for (int x = 1; x <= 3; x++)
      for (int y = 1; y <= 3; y++) paint(x, y);
  }
}
int main() {
  char t1[10], t2[10], t3[10];
  for (int p = 1; p <= 3; p++) {
    for (int i = 1; i <= 3; i++) {
      scanf("%s %s %s\n", t1, t2, t3);
      for (int j = 1; j <= 3; j++) {
        square[p][1].points[i][j] = t1[j - 1];
        square[p][2].points[i][j] = t2[j - 1];
        square[p][3].points[i][j] = t3[j - 1];
      }
    }
    if (p != 2) scanf("\n");
  }
  int px, py;
  scanf("%d%d", &px, &py);
  for (int x = 1; x <= 3; x++)
    for (int y = 1; y <= 3; y++) {
      calcSquare(x, y);
    }
  checkNextPoint(px, py);
  for (int p = 1; p <= 3; p++) {
    for (int i = 1; i <= 3; i++) {
      for (int s = 1; s <= 3; s++) {
        for (int j = 1; j <= 3; j++) printf("%c", square[p][s].points[i][j]);
        if (s < 3) printf(" ");
      }
      printf("\n");
    }
    if (p < 3) printf("\n");
  }
  return 0;
}
