#include <bits/stdc++.h>
using namespace std;
char grid[10][10];
int x, y;
char c;
bool isfilled(int a, int b) {
  a = 3 * a - 2;
  b = 3 * b - 2;
  for (long long i = 0; i <= 2; ++i) {
    for (long long j = 0; j <= 2; ++j) {
      if (grid[i + a][j + b] == '.') return 0;
    }
  }
  return 1;
}
void fill(int a, int b) {
  a = 3 * a - 2;
  b = 3 * b - 2;
  for (long long i = 0; i <= 2; ++i) {
    for (long long j = 0; j <= 2; ++j) {
      if (grid[i + a][j + b] == '.') grid[i + a][j + b] = '!';
    }
  }
}
int main() {
  bool f = 0;
  for (long long i = 1; i <= 9; ++i) {
    for (long long j = 1; j <= 9; ++j) {
      scanf(" %c", &c);
      if (c == '.') {
        grid[i][j] = '.';
      }
      if (c == 'x') {
        grid[i][j] = 'x';
        f = 1;
      }
      if (c == 'o') {
        grid[i][j] = 'o';
        f = 1;
      }
    }
  }
  scanf(" %d %d", &x, &y);
  int cx = x % 3;
  if (cx == 0) cx = 3;
  int cy = y % 3;
  if (cy == 0) cy = 3;
  if (!f) {
    for (long long i = 1; i <= 3; ++i) {
      for (long long j = 1; j <= 3; ++j) {
        fill(i, j);
      }
    }
  } else if (isfilled(cx, cy)) {
    for (long long i = 1; i <= 3; ++i) {
      for (long long j = 1; j <= 3; ++j) {
        if (cx != i || cy != j) fill(i, j);
      }
    }
  } else
    fill(cx, cy);
  for (long long cnt = 1; cnt <= 3; ++cnt) {
    for (long long q = 0; q <= 2; ++q) {
      for (long long i = 1; i <= 3; ++i) {
        for (long long j = 1; j <= 3; ++j) {
          printf("%c", grid[3 * cnt - 2 + q][j - 1 + 3 * i - 2]);
        }
        printf(" ");
      }
      printf("\n");
    }
    printf("\n");
  }
}
