#include <bits/stdc++.h>
int count[3][3];
char field[9][9];
int main() {
  for (int i = 0; i < 9; ++i) {
    for (int j = 0; j < 9; ++j) {
      std::cin >> field[i][j];
      if (field[i][j] == '.') {
        count[i / 3][j / 3]++;
      }
    }
  }
  int x, y;
  std::cin >> y >> x;
  y--;
  x--;
  int l_bound = 0, r_bound = 9, t_bound = 9, b_bound = 0;
  if (count[y % 3][x % 3]) {
    l_bound = x % 3 * 3;
    r_bound = l_bound + 3;
    b_bound = y % 3 * 3;
    t_bound = b_bound + 3;
  }
  for (int i = 0; i < 9; ++i) {
    for (int j = 0; j < 9; ++j) {
      if (l_bound <= j && j < r_bound && b_bound <= i && i < t_bound &&
          field[i][j] == '.') {
        std::cout << '!';
      } else {
        std::cout << field[i][j];
      }
      if (j == 2 || j == 5) {
        std::cout << ' ';
      }
    }
    std::cout << std::endl;
    if (i == 2 || i == 5) {
      std::cout << std::endl;
    }
  }
  return 0;
}
