#include <bits/stdc++.h>
using namespace std;
int main() {
  char spots[9][9];
  for (int i = 0; i < 9; i++) {
    for (int j = 0; j < 3; j++) {
      string input;
      cin >> input;
      for (int k = 0; k < input.size(); k++) {
        spots[i][j * 3 + k] = input[k];
      }
    }
  }
  int first, second;
  cin >> first >> second;
  first--;
  second--;
  int targetedFirst = first % 3;
  int targetedSecond = second % 3;
  bool changed = false;
  for (int i = targetedFirst * 3; i < targetedFirst * 3 + 3; i++) {
    for (int j = targetedSecond * 3; j < targetedSecond * 3 + 3; j++) {
      if (spots[i][j] == '.') {
        changed = true;
        spots[i][j] = '!';
      }
    }
  }
  if (changed == false) {
    for (int i = 0; i < 9; i++) {
      for (int j = 0; j < 9; j++) {
        if (spots[i][j] == '.') {
          spots[i][j] = '!';
        }
      }
    }
  }
  for (int i = 0; i < 9; i++) {
    for (int j = 0; j < 9; j++) {
      cout << spots[i][j];
      if (j % 3 == 2) {
        cout << " ";
      }
    }
    if (i % 3 == 2 && i != 8) {
      cout << endl;
    }
    cout << endl;
  }
  return 0;
}
