#include <bits/stdc++.h>
using namespace std;
const int INF = 1e9 + 1;
char b[10][10];
int x, y;
int stx[9] = {0, 0, 0, 3, 3, 3, 6, 6, 6};
int sty[9] = {0, 3, 6, 0, 3, 6, 0, 3, 6};
int main() {
  for (int i = 0; i < 9; i++) {
    for (int j = 0; j < 9; j++) {
      cin >> b[i][j];
    }
  }
  cin >> x >> y;
  x = (x - 1) % 3, y = (y - 1) % 3;
  int ans = x * 3 + y;
  bool ok = 0;
  for (int i = stx[ans]; i < stx[ans] + 3; i++) {
    for (int j = sty[ans]; j < sty[ans] + 3; j++) {
      if (b[i][j] == '.') ok = 1;
    }
  }
  if (ok) {
    for (int i = stx[ans]; i < stx[ans] + 3; i++) {
      for (int j = sty[ans]; j < sty[ans] + 3; j++) {
        if (b[i][j] == '.') b[i][j] = '!';
      }
    }
  } else {
    for (int i = 0; i < 9; i++) {
      for (int j = 0; j < 9; j++) {
        if (b[i][j] == '.') b[i][j] = '!';
      }
    }
  }
  for (int i = 0; i < 9; i++) {
    for (int j = 0; j < 9; j++) {
      cout << b[i][j];
      if (j % 3 == 2) cout << " ";
    }
    cout << endl;
    if (i % 3 == 2) cout << endl;
  }
  return 0;
}
