#include <bits/stdc++.h>
using namespace std;
signed main() {
  ios_base::sync_with_stdio(0);
  ;
  long long n = 9;
  vector<string> vec(n);
  for (long long i = 0; i < 9; i++) {
    for (long long j = 0; j < 3; j++) {
      string s;
      cin >> s;
      vec[i] += s;
    }
  }
  long long x, y;
  cin >> x >> y;
  x--;
  y--;
  x %= 3;
  y %= 3;
  bool any = 0;
  for (long long i = x * 3; i < x * 3 + 3; i++) {
    for (long long j = y * 3; j < y * 3 + 3; j++) {
      if (vec[i][j] == '.') {
        any = 1;
        vec[i][j] = '!';
      }
    }
  }
  if (any) {
    for (long long i = 0; i < 9; i++) {
      for (long long j = 0; j < 9; j++) {
        cout << vec[i][j];
        if (j % 3 == 2) cout << " ";
      }
      cout << "\n";
      if (i % 3 == 2) cout << "\n";
    }
  } else {
    for (long long i = 0; i < 9; i++) {
      for (long long j = 0; j < 9; j++) {
        if (vec[i][j] == '.') vec[i][j] = '!';
        cout << vec[i][j];
        if (j % 3 == 2) cout << " ";
      }
      cout << "\n";
      if (i % 3 == 2) cout << "\n";
    }
  }
  return 0;
}
