#include <bits/stdc++.h>
using namespace std;
long long int i, j, n, box;
char a[15][15];
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  for (i = 1; i <= 9; i++) {
    for (j = 1; j <= 9; j++) cin >> a[i][j];
  }
  long long int p1, p2;
  cin >> p1 >> p2;
  long long int r = p1 % 3;
  long long int c = p2 % 3;
  if (r == 0) r = 3;
  if (c == 0) c = 3;
  long long int rs, cs;
  if (r == 1) rs = 1;
  if (r == 2) rs = 4;
  if (r == 3) rs = 7;
  if (c == 1) cs = 1;
  if (c == 2) cs = 4;
  if (c == 3) cs = 7;
  long long int flag = 0;
  for (i = rs; i <= rs + 2; i++) {
    for (j = cs; j <= cs + 2; j++) {
      if (a[i][j] == '.') {
        a[i][j] = '!';
        flag = 1;
      }
    }
  }
  if (!flag) {
    for (i = 1; i <= 9; i++) {
      for (j = 1; j <= 9; j++) {
        if (a[i][j] == '.') {
          a[i][j] = '!';
        }
      }
    }
  }
  for (i = 1; i <= 9; i++) {
    for (j = 1; j <= 9; j++) {
      cout << a[i][j];
      if (j == 3 || j == 6) cout << " ";
    }
    if (i == 3 || i == 6) cout << endl;
    cout << endl;
  }
  return 0;
}
