#include <bits/stdc++.h>
using namespace std;
char to[100][100];
int main() {
  int i, j, n, m, x, y;
  for (i = 1; i < 10; i++) {
    for (j = 1; j < 10; j++) cin >> to[i][j];
  }
  cin >> n >> m;
  x = n;
  y = m;
  n = (n % 3 == 0) ? 3 : n % 3;
  m = (m % 3 == 0) ? 3 : m % 3;
  int flag = 0;
  for (i = (n - 1) * 3 + 1; i <= n * 3; i++) {
    for (j = (m - 1) * 3 + 1; j <= m * 3; j++) {
      if (to[i][j] == '.') {
        to[i][j] = '!';
        flag = 1;
      }
    }
  }
  if (!flag) {
    for (i = 1; i < 10; i++) {
      for (j = 1; j < 10; j++) {
        if (to[i][j] == '.') to[i][j] = '!';
        cout << to[i][j];
        if (j % 3 == 0 && j != 9) cout << " ";
      }
      if (i % 3 == 0 && i != 9) cout << endl;
      cout << endl;
    }
  } else {
    for (i = 1; i < 10; i++) {
      for (j = 1; j < 10; j++) {
        cout << to[i][j];
        if (j % 3 == 0 && j != 9) cout << " ";
      }
      if (i % 3 == 0 && i != 9) cout << endl;
      cout << endl;
    }
  }
  return 0;
}
