#include <bits/stdc++.h>
using namespace std;
int main() {
  char str[100][100];
  for (int i = 0; i < 9; i++)
    for (int j = 0; j < 9; j++) cin >> str[i][j];
  int x, y;
  cin >> x >> y;
  x--, y--;
  x %= 3;
  y %= 3;
  x *= 3;
  y *= 3;
  int flag = 0;
  for (int i = x; i < x + 3; i++)
    for (int j = y; j < y + 3; j++) {
      if (str[i][j] == '.') {
        flag = 1;
        str[i][j] = '!';
      }
    }
  if (!flag) {
    for (int i = 0; i < 9; i++) {
      for (int j = 0; j < 9; j++) {
        if (str[i][j] == '.') str[i][j] = '!';
      }
    }
  }
  for (int i = 0; i < 9; i++) {
    for (int j = 0; j < 9; j++) {
      cout << str[i][j];
      if (j == 2 || j == 5) cout << " ";
    }
    if (i == 2 || i == 5) cout << endl;
    cout << endl;
  }
  return 0;
}
