#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
constexpr int INF = 1e9;
constexpr ll INFLL = 1e18;
int main() {
  vector<string> fld(9);
  for (int i = 0; i < 9; ++i) {
    for (int j = 0; j < 3; ++j) {
      string s;
      cin >> s;
      fld[i] += s;
    }
  }
  int y, x;
  cin >> y >> x;
  y--;
  x--;
  int small_y = y % 3, small_x = x % 3;
  bool found = false;
  for (int i = small_y * 3; i < small_y * 3 + 3; ++i) {
    for (int j = small_x * 3; j < small_x * 3 + 3; ++j) {
      if (fld[i][j] == '.') {
        fld[i][j] = '!';
        found = true;
      }
    }
  }
  if (!found) {
    for (auto& s : fld) {
      for (auto& c : s) {
        if (c == '.') {
          c = '!';
        }
      }
    }
  }
  for (int i = 0; i < 9; ++i) {
    if (i == 3 || i == 6) {
      cout << endl;
    }
    for (int j = 0; j < 9; ++j) {
      if (j == 3 || j == 6) {
        cout << ' ';
      }
      cout << fld[i][j];
    }
    cout << endl;
  }
}
