#include <bits/stdc++.h>
using namespace std;
map<int, int> row;
map<int, int> col;
char graph[10][10];
int xi, yi;
int main() {
  for (int i = 1; i <= 9; ++i)
    scanf("%s %s %s", graph[i] + 1, graph[i] + 4, graph[i] + 7);
  scanf("%d%d", &xi, &yi);
  for (int i = 1; i <= 9; i += 3) row[i] = col[i] = 1;
  for (int i = 2; i <= 9; i += 3) row[i] = col[i] = 4;
  for (int i = 3; i <= 9; i += 3) row[i] = col[i] = 7;
  int r = row[xi];
  int c = col[yi];
  int flag = 0;
  int rr = r + 3, cc = c + 3;
  for (int i = r; i < rr; ++i)
    for (int j = c; j < cc; ++j)
      if (graph[i][j] == '.') {
        graph[i][j] = '!';
        flag = 1;
      }
  if (flag == 0)
    for (int i = 1; i <= 9; ++i)
      for (int j = 1; j <= 9; ++j)
        if (graph[i][j] == '.') graph[i][j] = '!';
  for (int i = 1; i <= 9; ++i) {
    for (int j = 1; j <= 9; ++j) {
      printf("%c", graph[i][j]);
      if (j == 3 || j == 6)
        printf(" ");
      else if (j == 9)
        printf("\n");
    }
    if (i % 3 == 0) printf("\n");
  }
  return 0;
}
