#include <bits/stdc++.h>
using namespace std;
const int inf = 0x3f3f3f3f;
const long long linf = 0x3f3f3f3fLL;
const int EPS = 1e-6;
char m[15][15][15];
int main() {
  for (int i = 0; i < 3; i++) {
    for (int j = 0; j < 3; j++) {
      scanf(" %s", m[j][i]);
    }
  }
  for (int i = 0; i < 3; i++) {
    for (int j = 3; j < 6; j++) {
      scanf(" %s", m[j][i]);
    }
  }
  for (int i = 0; i < 3; i++) {
    for (int j = 6; j < 9; j++) {
      scanf(" %s", m[j][i]);
    }
  }
  int x, y;
  scanf("%d %d", &x, &y);
  int ind = 0;
  x--;
  y--;
  while (((x % 3) * 3) + (y % 3) != ind) ind++;
  bool foi = false;
  for (int i = 0; i < 3; i++) {
    for (int j = 0; j < 3; j++) {
      if (m[ind][i][j] == '.') {
        foi = true;
        m[ind][i][j] = '!';
      }
    }
  }
  if (!foi) {
    for (int k = 0; k < 9; k++) {
      for (int i = 0; i < 3; i++) {
        for (int j = 0; j < 3; j++) {
          if (m[k][i][j] == '.') m[k][i][j] = '!';
        }
      }
    }
  }
  for (int i = 0; i < 3; i++) {
    for (int j = 0; j < 3; j++) {
      printf("%s ", m[j][i]);
    }
    printf("\n");
  }
  printf("\n");
  for (int i = 0; i < 3; i++) {
    for (int j = 3; j < 6; j++) {
      printf("%s ", m[j][i]);
    }
    printf("\n");
  }
  printf("\n");
  for (int i = 0; i < 3; i++) {
    for (int j = 6; j < 9; j++) {
      printf("%s ", m[j][i]);
    }
    printf("\n");
  }
  printf("\n");
  return 0;
}
