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