#include <bits/stdc++.h>
using namespace std;
int main() {
  char st[10][10];
  for (int i = 0; i < 9; i++) {
    for (int j = 0; j < 9; j++) {
      cin >> st[i][j];
    }
  }
  int a, b;
  cin >> a >> b;
  int ca1 = 0, ca2 = 0;
  if (a == 1 || a == 4 || a == 7) {
    if (b == 1 || b == 4 || b == 7) {
      ca1 = 0;
      ca2 = 0;
    } else if (b == 2 || b == 5 || b == 8) {
      ca1 = 1;
      ca2 = 0;
    } else {
      ca1 = 2, ca2 = 0;
    }
  } else if (a == 2 || a == 5 || a == 8) {
    if (b == 1 || b == 4 || b == 7) {
      ca1 = 0;
      ca2 = 1;
    } else if (b == 2 || b == 5 || b == 8) {
      ca1 = 1;
      ca2 = 1;
    } else {
      ca1 = 2;
      ca2 = 1;
    }
  } else {
    if (b == 1 || b == 4 || b == 7) {
      ca1 = 0;
      ca2 = 2;
    } else if (b == 2 || b == 5 || b == 8) {
      ca1 = 1;
      ca2 = 2;
    } else {
      ca1 = 2;
      ca2 = 2;
    }
  }
  bool flag = false;
  for (int i = 3 * ca2; i < 3 * (ca2 + 1); i++) {
    for (int j = 3 * ca1; j < 3 * (ca1 + 1); j++) {
      if (st[i][j] == '.') {
        flag = true;
        st[i][j] = '!';
      }
    }
  }
  for (int i = 0; i < 9; i++) {
    for (int j = 0; j < 9; j++) {
      if (!flag && st[i][j] == '.')
        cout << "!";
      else
        cout << st[i][j];
      if (j % 3 == 2 && j != 8) cout << " ";
    }
    cout << endl;
    if (i % 3 == 2 && i != 8) cout << endl;
  }
}
