#include <bits/stdc++.h>
using namespace std;
int awda123 = 1;
constexpr double eps = 1e-13;
long long M = 1e9 + 7;
constexpr int N = 5e5 + 100;
long long qpower(long long x, long long p) {
  long long ans = 1;
  while (p) {
    if (p & 1) ans = ans * x % M;
    x = x * x % M;
    p >>= 1;
  }
  return ans;
}
auto print = [](int x) { cout << x << " "; };
int main() {
  ios::sync_with_stdio(false);
  char ch[20][20];
  for (int i = 0; i < 9; ++i)
    for (int j = 0; j < 9; ++j) cin >> ch[i][j];
  int x, y;
  cin >> x >> y;
  x--;
  y--;
  x %= 3;
  y %= 3;
  bool flag = 0;
  for (int i = x * 3; i <= x * 3 + 2; ++i)
    for (int j = y * 3; j <= y * 3 + 2; ++j) {
      if (ch[i][j] == '.') {
        flag = 1;
        ch[i][j] = '!';
      }
    }
  if (!flag) {
    for (int i = 0; i < 9; ++i)
      for (int j = 0; j < 9; ++j) {
        if (ch[i][j] == '.') ch[i][j] = '!';
      }
  }
  for (int i = 0; i < 9; ++i) {
    for (int j = 0; j < 9; ++j) {
      cout << ch[i][j];
      if (j % 3 == 2) cout << " ";
    }
    cout << endl;
    if (i % 3 == 2) cout << endl;
  }
}
