#include <bits/stdc++.h>
using namespace std;
int main() {
  vector<vector<char> > a(9, vector<char>(9));
  int ii = -1;
  for (int i = 0; i < 11; ++i) {
    string s;
    getline(cin, s);
    if (s.length() == 0 || s[0] == ' ') {
      continue;
    }
    ++ii;
    int jj = -1;
    for (int j = 0; j < 11; ++j) {
      if (s[j] == ' ') {
        continue;
      }
      ++jj;
      a[ii][jj] = s[j];
    }
  }
  int x, y;
  cin >> x >> y;
  --x;
  --y;
  x %= 3;
  y %= 3;
  bool flag = 0;
  for (int i = x * 3; i < x * 3 + 3; ++i) {
    for (int j = y * 3; j < y * 3 + 3; ++j) {
      if (a[i][j] == '.') {
        flag = 1;
        a[i][j] = '!';
      }
    }
  }
  if (!flag) {
    for (int i = 0; i < 9; ++i) {
      for (int j = 0; j < 9; ++j) {
        if (a[i][j] == '.') {
          a[i][j] = '!';
        }
      }
    }
  }
  for (int i = 0; i < 9; ++i) {
    if (i != 0 && i % 3 == 0) {
      cout << endl;
    }
    for (int j = 0; j < 9; ++j) {
      if (j != 0 && j % 3 == 0) {
        cout << " ";
      }
      cout << a[i][j];
    }
    cout << endl;
  }
  return 0;
}
