#include <bits/stdc++.h>
using namespace std;
const long double PI =
    3.14159265358979323846264338327950288419716939937510582097494459230;
const long long MOD = 1000000007LL;
const long long INF = 1e9;
const long long LINF = 1e18;
const long double EPS = 1e-9;
const long double GOLD = ((1 + sqrt(5)) / 2);
template <class T>
int getbit(T s, int i) {
  return (s >> 1) & 1;
}
template <class T>
T onbit(T s, int i) {
  return s | (T(1) << i);
}
template <class T>
T offbit(T s, int i) {
  return s & (~(T(1) << i));
}
template <class T>
int cntbit(T s) {
  return __builtin_popcount(s);
}
char a[9][9];
long long x, y, cc = 0;
void VarInput() {
  for (long long i = 0; i < 9; i++) {
    for (long long j = 0; j < 9; j++) cin >> a[i][j];
  }
  cin >> x >> y;
  x--;
  y--;
  x %= 3;
  y %= 3;
  for (long long i = 0; i < 3; i++) {
    for (long long j = 0; j < 3; j++) {
      if (a[3 * x + i][3 * y + j] == '.') {
        cc++;
        a[3 * x + i][3 * y + j] = '!';
      }
    }
  }
}
void ProSolve() {
  for (long long i = 0; i < 9; i++) {
    for (long long j = 0; j < 9; j++) {
      if (a[i][j] != '.')
        cout << a[i][j];
      else if (cc == 0)
        cout << '!';
      else
        cout << '.';
      if (j % 3 == 2) cout << " ";
    }
    cout << '\n';
    if (i % 3 == 2) cout << '\n';
  }
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(NULL);
  VarInput();
  ProSolve();
  return 0;
}
