#include <bits/stdc++.h>
using namespace std;
char a[15][15] = {'\0'};
int main() {
  ios::sync_with_stdio(0);
  for (int i = 1; i <= 9; i++) {
    for (int j = 1; j <= 9; j++) {
      cin >> a[i][j];
    }
  }
  int x, y;
  cin >> x >> y;
  x %= 3;
  y %= 3;
  if (x == 0) x = 3;
  if (y == 0) y = 3;
  int cnt = 0;
  for (int i = (x - 1) * 3 + 1; i <= x * 3; i++) {
    for (int j = (y - 1) * 3 + 1; j <= y * 3; j++) {
      if (a[i][j] == '.') {
        a[i][j] = '!';
        cnt++;
      }
    }
  }
  if (cnt == 0) {
    for (int i = 1; i <= 9; i++) {
      for (int j = 1; j <= 9; j++) {
        if (a[i][j] == '.') a[i][j] = '!';
      }
    }
  }
  for (int i = 1; i <= 9; i++) {
    for (int j = 1; j <= 9; j++) {
      cout << a[i][j];
      if (j % 3 == 0) cout << " ";
    }
    cout << "\n";
    if (i % 3 == 0) cout << "\n";
  }
  return 0;
}
