#include <bits/stdc++.h>
using namespace std;
const long long INF = (1LL << 60);
const double PI = 3.14159265359;
const double EPS = 1e-12;
const long long MOD = 1000000007;
template <typename T>
T &chmin(T &a, const T &b) {
  return a = min(a, b);
}
template <typename T>
T &chmax(T &a, const T &b) {
  return a = max(a, b);
}
template <class S, class T>
ostream &operator<<(ostream &out, const pair<S, T> &a) {
  out << '(' << a.first << ',' << a.second << ')';
  return out;
}
long long dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0};
string s[9][3];
signed main(void) {
  for (long long i = (long long)0; i < (long long)9; ++i)
    for (long long j = (long long)0; j < (long long)3; ++j) cin >> s[i][j];
  long long y, x;
  cin >> y >> x;
  y--, x--;
  y %= 3, x %= 3;
  bool flag = false;
  for (long long i = (long long)0; i < (long long)3; ++i)
    for (long long j = (long long)0; j < (long long)3; ++j) {
      if (s[3 * y + i][x][j] == '.') flag = true;
    }
  if (flag) {
    for (long long i = (long long)0; i < (long long)3; ++i)
      for (long long j = (long long)0; j < (long long)3; ++j) {
        if (s[3 * y + i][x][j] == '.') s[3 * y + i][x][j] = '!';
      }
    for (long long i = (long long)0; i < (long long)9; ++i) {
      for (long long j = (long long)0; j < (long long)3; ++j) {
        cout << s[i][j];
        if (j != 2) cout << " ";
      }
      cout << endl;
      if (i % 3 == 2) cout << endl;
    }
    return 0;
  }
  for (long long i = (long long)0; i < (long long)9; ++i)
    for (long long j = (long long)0; j < (long long)3; ++j)
      for (long long k = (long long)0; k < (long long)3; ++k) {
        if (s[i][j][k] == '.') s[i][j][k] = '!';
      }
  for (long long i = (long long)0; i < (long long)9; ++i) {
    for (long long j = (long long)0; j < (long long)3; ++j) {
      cout << s[i][j];
      if (j != 2) cout << " ";
    }
    cout << endl;
    if (i % 3 == 2) cout << endl;
  }
  return 0;
}
