#include <bits/stdc++.h>
using namespace std;
int n, m, nm, p, t, ans;
char a[10][10];
int main() {
  ios_base::sync_with_stdio(false);
  for (int i = 1; i < 10; i++)
    for (int j = 1; j < 10; j++) cin >> a[i][j];
  cin >> p >> t;
  char c = a[p][t];
  p %= 3;
  t %= 3;
  if (!p) p = 3;
  if (!t) t = 3;
  int x = (p - 1) * 3, y = (t - 1) * 3;
  bool yes = false;
  for (int i = 1; i < 4; i++)
    for (int j = 1; j < 4; j++) {
      if (a[i + x][j + y] == '.') {
        a[i + x][j + y] = '!';
        yes = true;
      }
    }
  if (!yes)
    for (int i = 1; i < 10; i++)
      for (int j = 1; j < 10; j++) {
        if (a[i][j] == '.') {
          a[i][j] = '!';
        }
      }
  for (int i = 1; i < 10; i++)
    for (int j = 1; j < 10; j++) {
      cout << a[i][j];
      if (j == 3 || j == 6) cout << " ";
      if (j == 9) {
        cout << endl;
        if (i == 3 || i == 6) cout << endl;
      }
    }
  return 0;
}
