#include <bits/stdc++.h>
using namespace std;
char a[12][12];
int num[9][9] = {1, 2, 3, 1, 2, 3, 1, 2, 3, 4, 5, 6, 4, 5, 6, 4, 5, 6, 7, 8, 9,
                 7, 8, 9, 7, 8, 9, 1, 2, 3, 1, 2, 3, 1, 2, 3, 4, 5, 6, 4, 5, 6,
                 4, 5, 6, 7, 8, 9, 7, 8, 9, 7, 8, 9, 1, 2, 3, 1, 2, 3, 1, 2, 3,
                 4, 5, 6, 4, 5, 6, 4, 5, 6, 7, 8, 9, 7, 8, 9, 7, 8, 9};
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  for (int i = 1; i <= 9; i++)
    for (int j = 1; j <= 9; j++) cin >> a[i][j];
  int x, y;
  cin >> x >> y;
  int t = num[x - 1][y - 1];
  int tup = 1 + (t - 1) / 3 * 3;
  int tdown = tup + 2;
  int tleft = 1 + (t - 1) % 3 * 3;
  int tright = tleft + 2;
  int kol = 0;
  for (int i = tup; i <= tdown; i++)
    for (int j = tleft; j <= tright; j++)
      if (a[i][j] == '.') kol++;
  if (kol != 0) {
    for (int i = tup; i <= tdown; i++)
      for (int j = tleft; j <= tright; j++)
        if (a[i][j] == '.') a[i][j] = '!';
  } else {
    for (int i = 1; i <= 9; i++)
      for (int j = 1; j <= 9; j++)
        if (a[i][j] == '.') a[i][j] = '!';
  }
  for (int i = 1; i <= 9; i++) {
    for (int j = 1; j <= 9; j++) {
      cout << a[i][j];
      if (j % 3 == 0 && j != 9) cout << ' ';
    }
    if (i % 3 == 0 && i != 9) cout << '\n';
    cout << '\n';
  }
  return 0;
}
