#include <bits/stdc++.h>
using namespace std;
int main() {
  char tab[9][9];
  for (int i = 0; i < 9; i++) {
    for (int j = 0; j < 9; j++) {
      cin >> tab[i][j];
    }
  }
  int r, c;
  cin >> r >> c;
  if (r % 3 == 0)
    r = 3;
  else if (r % 3 == 2)
    r = 2;
  else
    r = 1;
  if (c % 3 == 0)
    c = 3;
  else if (c % 3 == 2)
    c = 2;
  else
    c = 1;
  r--;
  c--;
  bool ok = false;
  for (int i = r * 3; i < (r * 3) + 3; i++) {
    for (int j = c * 3; j < (c * 3) + 3; j++) {
      if (tab[i][j] == '.') {
        tab[i][j] = '!';
        ok = true;
      }
    }
  }
  if (ok)
    for (int i = 0; i < 9; i++) {
      for (int j = 0; j < 9; j++) {
        if (j == 3 || j == 6) cout << " ";
        cout << tab[i][j];
      }
      cout << endl;
      if (i == 2 || i == 5) cout << endl;
    }
  else
    for (int i = 0; i < 9; i++) {
      for (int j = 0; j < 9; j++) {
        if (j == 3 || j == 6) cout << " ";
        if (tab[i][j] == '.')
          cout << "!";
        else
          cout << tab[i][j];
      }
      cout << endl;
      if (i == 2 || i == 5) cout << endl;
    }
}
