#include <bits/stdc++.h>
using namespace std;
char s[3][3][3][4], ss[5];
int x, y, p[3][3];
signed main() {
  for (int i = 0; i < 9; i++)
    for (int j = 0; j < 3; j++) {
      cin >> ss;
      for (int k = 0; k < 3; k++) {
        int x = i % 3, y = (j * 3 + k) % 3;
        int a = i / 3, b = j;
        s[a][b][x][y] = ss[k];
        if (ss[k] == '.') p[a][b] = 1;
      }
    }
  cin >> x >> y;
  x = (x - 1) % 3, y = (y - 1) % 3;
  if (p[x][y]) {
    for (int i = 0; i < 3; i++)
      for (int j = 0; j < 3; j++)
        if (s[x][y][i][j] == '.') s[x][y][i][j] = '!';
  } else {
    for (int i = 0; i < 3; i++)
      for (int j = 0; j < 3; j++)
        for (int k = 0; k < 3; k++)
          for (int l = 0; l < 3; l++)
            if (s[i][j][k][l] == '.') s[i][j][k][l] = '!';
  }
  for (int i = 0; i < 3; i++, puts(""))
    for (int j = 0; j < 3; j++, puts(""))
      for (int k = 0; k < 3; k++, putchar(' ')) printf("%s", s[i][k][j]);
}
