#include <bits/stdc++.h>
using namespace std;
pair<char, pair<long long int, long long int> > arr[20][20];
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long int i, j, ii, jj, f = 0;
  for (i = 1; i <= 9; i++) {
    for (j = 1; j <= 9; j++) cin >> arr[i][j].first;
  }
  for (i = 1; i <= 9; i++) {
    for (j = 1; j <= 9; j++) {
      arr[i][j].second.first = (i - 1) / 3 + 1;
      arr[i][j].second.second = (j - 1) / 3 + 1;
    }
  }
  cin >> ii >> jj;
  ii = ii % 3;
  jj = jj % 3;
  if (ii == 0) ii = 3;
  if (jj == 0) jj = 3;
  for (i = 1; i <= 9; i++) {
    for (j = 1; j <= 9; j++) {
      if (arr[i][j].second.first != ii) continue;
      if (arr[i][j].second.second != jj) continue;
      if (arr[i][j].first == '.') {
        arr[i][j].first = '!';
        f = 1;
      }
    }
  }
  for (i = 1; i <= 9; i++) {
    for (j = 1; j <= 9; j++) {
      if (arr[i][j].first != '.')
        cout << arr[i][j].first;
      else {
        if (f == 1)
          cout << ".";
        else
          cout << "!";
      }
      if (j % 3 == 0) cout << " ";
    }
    cout << "\n";
    if (i % 3 == 0) cout << "\n";
  }
  return 0;
}
