#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  string s[10];
  for (int i = 1; i <= 9; i++) {
    getline(cin, s[i]);
    if (s[i] == "") i--;
  }
  int x, y;
  cin >> x >> y;
  int a = x % 3, b = y % 3;
  if (a == 0) a = 3;
  if (b == 0) b = 3;
  for (int i = 1; i <= 9; i++) {
    s[i] = s[i].substr(0, 3) + s[i].substr(4, 3) + s[i].substr(8, 3);
  }
  bool po = false;
  ;
  for (int i = (a - 1) * 3 + 1; i <= (a - 1) * 3 + 3; i++) {
    for (int j = (b - 1) * 3; j <= (b - 1) * 3 + 2; j++) {
      if (s[i][j] == '.') po = true, s[i][j] = '!';
    }
  }
  if (po == false) {
    for (int i = 1; i <= 9; i++) {
      for (int j = 0; j <= 8; j++) {
        if (!((a - 1) * 3 + 1 <= i && i <= (a - 1) * 3 + 3 &&
              (b - 1) * 3 <= j && j <= (b - 1) * 3 + 2) &&
            s[i][j] == '.')
          s[i][j] = '!';
      }
    }
  }
  for (int i = 1; i <= 3; i++)
    cout << s[i].substr(0, 3) + " " + s[i].substr(3, 3) + " " +
                s[i].substr(6, 3)
         << endl;
  cout << endl;
  for (int i = 4; i <= 6; i++)
    cout << s[i].substr(0, 3) + " " + s[i].substr(3, 3) + " " +
                s[i].substr(6, 3)
         << endl;
  cout << endl;
  for (int i = 7; i <= 9; i++)
    cout << s[i].substr(0, 3) + " " + s[i].substr(3, 3) + " " +
                s[i].substr(6, 3)
         << endl;
}
