#include <bits/stdc++.h>
using namespace std;
void fre() {}
long long gcd(long long a, long long b) { return !b ? a : gcd(b, a % b); }
long long lcm(long long a, long long b) { return (a / gcd(a, b)) * b; }
int FixMod(int s, int k) { return (s % k + k) % k; }
double dic(pair<int, int> a, pair<int, int> b) {
  return (sqrt((a.first - b.first) * (a.first - b.first) +
               (a.second - b.second) * (a.second - b.second)));
}
enum dir {
  DOWN = 0,
  UP,
  RIGHT,
  LEFT,
  DOWN_RIGHT,
  DOWN_LEFT,
  UP_RIGHT,
  UP_LEFT
};
int dir_r[] = {1, -1, 0, 0, 1, 1, -1, -1};
int dir_c[] = {0, 0, 1, -1, 1, -1, 1, -1};
int recorrerA[8] = {-2, -1, 1, 2, 2, 1, -1, -2};
int recorrerB[8] = {1, 2, 2, 1, -1, -2, -2, -1};
char a[9][9];
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  for (int i = 0; i < 9; i++) {
    for (int j = 0; j < 9; j++) {
      cin >> a[i][j];
    }
  }
  int x, y;
  cin >> x >> y;
  x--;
  y--;
  x %= 3;
  y %= 3;
  bool f = 0;
  for (int i = x * 3; i < x * 3 + 3; i++) {
    for (int j = y * 3; j < y * 3 + 3; j++) {
      if (a[i][j] == '.') {
        f = 1;
        a[i][j] = '!';
      }
    }
  }
  for (int i = 0; i < 9; i++) {
    if (i && i % 3 == 0) cout << '\n';
    for (int j = 0; j < 9; j++) {
      if (j && j % 3 == 0) cout << ' ';
      if (!f && a[i][j] == '.') a[i][j] = '!';
      cout << a[i][j];
    }
    cout << '\n';
  }
  return 0;
}
