#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  vector<vector<char> > field(9, vector<char>(9, '.'));
  string state;
  for (int i = 0; i < 9; i++) {
    for (int j = 0; j < 3; j++) {
      cin >> state;
      for (int k = 1; k <= 3; k++) {
        field[i][(j * 3) + k - 1] = state[k - 1];
      }
    }
  }
  int x, y;
  bool any = true;
  cin >> x >> y;
  while (x > 3) {
    x -= 3;
  }
  while (y > 3) {
    y -= 3;
  }
  x--;
  y--;
  for (int i = x * 3; i < (x + 1) * 3; i++) {
    for (int j = y * 3; j < (y + 1) * 3; j++) {
      if (field[i][j] == '.') {
        any = false;
        field[i][j] = '!';
      }
    }
  }
  for (int i = 0; i < 9; i++) {
    for (int j = 0; j < 9; j++) {
      if (field[i][j] == '.' && any)
        cout << '!';
      else
        cout << field[i][j];
      if ((j + 1) % 3 == 0) cout << " ";
    }
    cout << "\n";
    if ((i + 1) % 3 == 0) cout << "\n";
  }
}
