#include <bits/stdc++.h>
#pragma GCC optimize("omit-frame-pointer")
#pragma GCC optimize("unroll-loops")
using namespace std;
string itosm(long long x) {
  if (x == 0) return "0";
  string ans = "";
  while (x > 0) {
    ans += ((x % 10) + '0');
    x /= 10;
  }
  reverse(ans.begin(), ans.end());
  return ans;
}
long long stoim(string str) {
  long long ans = 0;
  long long k = 1;
  for (int i = str.length() - 1; i >= 0; i--) {
    ans += (str[i] - '0') * k;
    k *= 10;
  }
  return ans;
}
const long long infll = 1e18 + 3;
const int inf = 1009000999;
const double eps = 1e-7;
const int maxn = 1e6 + 46;
const int baseint = 1000200013;
const long long basell = 1e18 + 3;
const long double PI = acos(-1.0);
const long long mod = 1e9 + 7;
char c[9][9];
void solve() {
  for (int i = 0; i < 9; i++)
    for (int j = 0; j < 9; j++) cin >> c[i][j];
  int x, y;
  cin >> x >> y;
  x = (x - 1) % 3;
  y = (y - 1) % 3;
  x *= 3;
  y *= 3;
  bool fff = 0;
  for (int i = 0; i < 3; i++)
    for (int j = 0; j < 3; j++)
      if (c[x + i][y + j] == '.') {
        c[x + i][y + j] = '!';
        fff = 1;
      }
  if (!fff) {
    for (int i = 0; i < 9; i++)
      for (int j = 0; j < 9; j++)
        if (c[i][j] == '.') c[i][j] = '!';
  }
  for (int i = 0; i < 9; i++) {
    cout << c[i][0] << c[i][1] << c[i][2] << " " << c[i][3] << c[i][4]
         << c[i][5] << " " << c[i][6] << c[i][7] << c[i][8] << "\n";
    if (i == 2 || i == 5) cout << "\n";
  }
}
int main() {
  srand(time(0));
  ios_base::sync_with_stdio(0);
  ;
  cin.tie(0);
  solve();
  return 0;
}
