#include <bits/stdc++.h>
using namespace std;
const int MOD = int(1e9) + 7;
const int MAX = 2e5 + 5;
signed main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  char arr[9][9];
  for (int long long i = 0; i < 9; ++i)
    for (int long long j = 0; j < 9; ++j) {
      cin >> arr[i][j];
    }
  int long long x, y;
  cin >> x >> y;
  pair<int long long, int long long> dp[3][3];
  dp[1][1] = {0, 0};
  dp[1][2] = {0, 3};
  dp[1][0] = {0, 6};
  dp[2][1] = {3, 0};
  dp[2][2] = {3, 3};
  dp[2][0] = {3, 6};
  dp[0][1] = {6, 0};
  dp[0][2] = {6, 3};
  dp[0][0] = {6, 6};
  auto [a, b] = dp[x % 3][y % 3];
  bool flag = false;
  for (int long long i = a; i < a + 3; ++i) {
    for (int long long j = b; j < b + 3; ++j) {
      if (arr[i][j] == '.') {
        flag = true;
        arr[i][j] = '!';
      }
    }
  }
  if (!flag) {
    for (int long long i = 0; i < 9; ++i) {
      for (int long long j = 0; j < 9; ++j) {
        if (i >= a && i < a + 3 && j >= b && j < b + 3) continue;
        if (arr[i][j] == '.') arr[i][j] = '!';
      }
    }
  }
  int long long cnta = 0;
  for (int long long i = 0; i < 9; ++i, cout << '\n') {
    int long long cnt = 0;
    for (int long long j = 0; j < 9; ++j) {
      cout << arr[i][j];
      if (j % 3 == 2 && cnt < 2) {
        ++cnt;
        cout << " ";
      }
    }
    if (i % 3 == 2 && cnta < 2) {
      cout << '\n';
      ++cnta;
    }
  }
}
