#include <bits/stdc++.h>
using namespace std;
char mp[10][10];
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  for (int i = 1; i <= 9; i++)
    for (int j = 1; j <= 9; j++) cin >> mp[i][j];
  int x, y;
  cin >> x >> y;
  x = (x + 2) % 3, y = (y + 2) % 3;
  int flag = 0;
  for (int i = x * 3 + 1; i <= x * 3 + 3; i++) {
    for (int j = y * 3 + 1; j <= y * 3 + 3; j++) {
      if (mp[i][j] == '.') flag = 1, mp[i][j] = '!';
    }
  }
  if (!flag) {
    for (int i = 1; i <= 9; i++)
      for (int j = 1; j <= 9; j++)
        if (mp[i][j] == '.') mp[i][j] = '!';
  }
  for (int i = 1; i <= 9; i++) {
    for (int j = 1; j <= 9; j++) cout << mp[i][j] << (j % 3 == 0 ? " " : "");
    cout << "\n" << (i % 3 == 0 ? "\n" : "");
  }
}
