#include <bits/stdc++.h>
#pragma GCC optimize("O3")
std::pair<int, int> DR[] = {{-1, 0}, {0, 1},   {1, 0}, {0, -1},
                            {-1, 1}, {-1, -1}, {1, 1}, {1, -1}};
using namespace std;
string ans[100];
int A[100][100];
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cerr.tie(0);
  cout.tie(0);
  int idx1 = 1;
  for (int i = 1; i <= 11; i++) {
    string s;
    getline(cin, s);
    if (s != "") {
      int idx = 1;
      for (int j = 0; j < (int)((s).size()); j++) {
        if (s[j] == ' ') continue;
        A[idx1][idx] = (s[j] != '.');
        idx++;
      }
      idx1++;
    }
    ans[i] = s;
  }
  int x, y;
  cin >> x >> y;
  x--;
  x %= 3;
  y--;
  y %= 3;
  bool B = 0;
  for (int i = 1; i <= 9; i++) {
    for (int j = 1; j <= 9; j++) {
      int a = i - 1;
      int b = j - 1;
      a /= 3;
      b /= 3;
      if (a == x && b == y && !A[i][j]) {
        A[i][j] = 2;
        B = 1;
      }
    }
  }
  if (B == 0) {
    for (int i = 1; i <= 9; i++) {
      for (int j = 1; j <= 9; j++) {
        if (A[i][j] == 0) A[i][j] = 2;
      }
    }
  }
  idx1 = 1;
  for (int i = 1; i <= 11; i++) {
    int idx = 1;
    for (int j = 0; j < (int)((ans[i]).size()); j++) {
      if (ans[i][j] == ' ') continue;
      if (A[idx1][idx] == 2) ans[i][j] = '!';
      idx++;
    }
    if (ans[i] != "") idx1++;
    cout << ans[i] << '\n';
  }
  cout << '\n';
}
