#include <bits/stdc++.h>
using namespace std;
int main() {
  char inp[3][3][3][3] = {};
  string mat[9];
  for (int i = 0; i < 9; i++) {
    getline(cin, mat[i]);
    if (mat[i] == "") i--;
  }
  for (int i = 0; i < 9; i++) {
    mat[i].erase(7, 1);
    mat[i].erase(3, 1);
  }
  for (int i = 0; i < 9; i++)
    for (int j = 0; j < 9; j++) inp[i / 3][j / 3][i % 3][j % 3] = mat[i][j];
  int x, y;
  cin >> x >> y;
  x--;
  y--;
  int flg = 1;
  for (int i = 0; i < 3; i++)
    for (int j = 0; j < 3; j++)
      if (inp[x % 3][y % 3][i][j] == '.') {
        inp[x % 3][y % 3][i][j] = '!';
        flg = 0;
      }
  if (flg == 1)
    for (int i = 0; i < 9; i++)
      for (int j = 0; j < 9; j++)
        if (inp[i / 3][j / 3][i % 3][j % 3] == '.')
          inp[i / 3][j / 3][i % 3][j % 3] = '!';
  char out[9][9] = {};
  for (int i = 0; i < 9; i++)
    for (int j = 0; j < 9; j++) out[i][j] = inp[i / 3][j / 3][i % 3][j % 3];
  for (int i = 0; i < 9; i++) {
    for (int j = 0; j < 9; j++) {
      cout << out[i][j];
      if (j == 2 || j == 5) cout << ' ';
    }
    if (i == 2 || i == 5) cout << '\n';
    cout << '\n';
  }
  return 0;
}
