#include <bits/stdc++.h>
using namespace std;
char field[9][9];
int main() {
  for (int i = 0; i < 9; i++) {
    for (int j = 0; j < 9; j++) {
      cin >> field[i][j];
    }
  }
  int a, b;
  cin >> a >> b;
  a--;
  b--;
  a %= 3;
  b %= 3;
  bool bl = false;
  for (int i = a * 3; i < a * 3 + 3; i++) {
    for (int j = b * 3; j < b * 3 + 3; j++) {
      if (field[i][j] == '.') {
        bl = true;
        field[i][j] = '!';
      }
    }
  }
  if (!bl) {
    for (int i = 0; i < 9; i++) {
      for (int j = 0; j < 9; j++) {
        if (field[i][j] == '.') {
          field[i][j] = '!';
        }
      }
    }
  }
  for (int i = 0; i < 9; i++) {
    for (int j = 0; j < 9; j++) {
      cout << field[i][j];
      if (j % 3 == 2) {
        cout << " ";
      }
    }
    cout << endl;
    if (i % 3 == 2) {
      cout << endl;
    }
  }
}
