#include <bits/stdc++.h>
using namespace std;
int main() {
  char m[9][9];
  char ha;
  int h = 0, k = 0;
  while (h < 9) {
    cin >> ha;
    if ((ha == '.') || (ha == 'x') || (ha == 'o')) {
      m[h][k] = ha;
      k++;
      if (k == 9) {
        k = 0;
        h++;
      }
    }
  }
  int x, y;
  cin >> x >> y;
  bool exi = false;
  x--;
  y--;
  int g = (x % 3) * 3;
  int s = (y % 3) * 3;
  for (int i = g; i < g + 3; i++) {
    for (int j = s; j < s + 3; j++) {
      if (m[i][j] == '.') {
        exi = true;
        break;
      }
    }
  }
  if (exi) {
    for (int i = g; i < g + 3; i++) {
      for (int j = s; j < s + 3; j++) {
        if (m[i][j] == '.') {
          m[i][j] = '!';
        }
      }
    }
  } else {
    for (int i = 0; i < 9; i++) {
      for (int j = 0; j < 9; j++) {
        if (m[i][j] == '.') {
          m[i][j] = '!';
        }
      }
    }
  }
  for (int i = 0; i < 9; i++) {
    if ((i != 0) && (i % 3 == 0)) {
      cout << endl;
    }
    for (int j = 0; j < 9; j++) {
      if ((j != 0) && (j % 3 == 0)) {
        cout << " ";
      }
      cout << m[i][j];
    }
    cout << endl;
  }
  cout << endl;
}
