#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  vector<vector<string> > play(9, vector<string>(3));
  for (int i = 0; i <= 8; i++) {
    for (int j = 0; j < 3; j++) {
      cin >> play[i][j];
    }
  }
  int arr[3][3] = {{0, 1, 2}, {3, 4, 5}, {6, 7, 8}};
  int a, b;
  cin >> a >> b;
  a--;
  b--;
  a %= 3;
  b %= 3;
  bool ok = false;
  for (auto x : arr[a]) {
    for (auto y : arr[0]) {
      if (play[x][b][y] == '.') {
        if (!ok) ok = true;
        play[x][b][y] = '!';
      }
    }
  }
  if (!ok) {
    for (int i = 0; i < 9; i++) {
      for (int j = 0; j < 3; j++) {
        for (int k = 0; k < 3; k++) {
          if (play[i][j][k] == '.') {
            play[i][j][k] = '!';
          }
        }
      }
    }
  }
  for (int i = 0; i < 9; i++) {
    for (int j = 0; j < 3; j++) {
      cout << play[i][j] << ' ';
    }
    cout << '\n';
    if ((1 + i) % 3 == 0) cout << '\n';
  }
}
