#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  char a[9][9];
  for (int i = 0; i < 9; i++) {
    for (int j = 0; j < 9; j++) {
      cin >> a[i][j];
    }
  }
  int m, n;
  cin >> m >> n;
  m = (m - 1) % 3;
  n = (n - 1) % 3;
  bool l = false;
  for (int i = m * 3; i <= m * 3 + 2; i++) {
    for (int j = n * 3; j <= n * 3 + 2; j++) {
      if (a[i][j] == '.') l = true;
    }
  }
  if (l) {
    for (int i = m * 3; i <= m * 3 + 2; i++) {
      for (int j = n * 3; j <= n * 3 + 2; j++) {
        if (a[i][j] == '.') a[i][j] = '!';
      }
    }
    for (int i = 0; i < 9; i++) {
      for (int j = 0; j < 9; j++) {
        cout << a[i][j];
        if (j % 3 == 2) cout << ' ';
      }
      if (i % 3 == 2) cout << '\n';
      cout << '\n';
    }
  } else {
    for (int i = 0; i < 9; i++) {
      for (int j = 0; j < 9; j++) {
        if (a[i][j] == '.')
          cout << "!";
        else
          cout << a[i][j];
        if (j % 3 == 2) cout << ' ';
      }
      if (i % 3 == 2) cout << '\n';
      cout << '\n';
    }
  }
}
