#include <bits/stdc++.h>
using namespace std;
const int INF = (1 << 31) - 1;
const long long LINF = (1ll << 63) - 1;
const double DINF = numeric_limits<double>::infinity();
const int MOD = 1e9 + 7;
const double EPS = 1e-7;
long long gcd(long long a, long long b) { return b ? gcd(b, a % b) : a; }
mt19937 mmtw(MOD);
long long rnd(long long x, long long y) {
  static uniform_int_distribution<long long> d;
  return d(mmtw) % (y - x + 1) + x;
}
template <class T>
T binpow(T n, T k) {
  if (k == 1) return n;
  if (k & 1) return binpow(n, k - 1) * n;
  T a = binpow(n, k / 2);
  return a * a;
}
template <class T>
T fact(T n) {
  if (n == 1) return 1;
  return n * fact(n - 1);
}
string field[9];
string tmp;
int x, y;
int main() {
  for (int i = 0; i < 9; ++i) {
    for (int j = 0; j < 3; ++j) {
      cin >> tmp;
      field[i] += tmp;
    }
  }
  cin >> x >> y;
  x--;
  y--;
  x %= 3;
  y %= 3;
  bool flag = true;
  for (int i = 3 * x; i < 3 * x + 3; ++i) {
    for (int j = 3 * y; j < 3 * y + 3; ++j) {
      if (field[i][j] == '.') {
        field[i][j] = '!';
        flag = false;
      }
    }
  }
  if (flag) {
    for (int i = 0; i < 9; ++i) {
      for (int j = 0; j < 9; ++j) {
        if (field[i][j] == '.') {
          field[i][j] = '!';
        }
      }
    }
  }
  for (int i = 0; i < 9; ++i) {
    for (int k = 0; k < 3; ++k) {
      cout << field[i].substr(k * 3, 3);
      if (k != 2) {
        cout << " ";
      }
    }
    cout << endl;
    if (i == 2 || i == 5) {
      cout << endl;
    }
  }
}
