#include <bits/stdc++.h>
using namespace std;
const int num = 200001;
int main() {
  int a, b;
  string str[11];
  for (int i = 0; i < 11; i++) {
    getline(cin, str[i]);
  }
  cin >> a >> b;
  int row = (a - 1) % 3;
  int col = (b - 1) % 3;
  int r = 4 * row;
  int c = 4 * col;
  int flag = 0;
  for (int i = r; i < r + 3; i++) {
    for (int j = c; j < c + 3; j++) {
      if (str[i][j] == 'x' || str[i][j] == 'o')
        continue;
      else
        flag = 1, str[i][j] = '!';
    }
  }
  if (!flag) {
    for (int i = 0; i < 11; i++) {
      for (int j = 0; j < 11; j++) {
        if (str[i][j] == '.') str[i][j] = '!';
      }
    }
  }
  for (int i = 0; i < 11; i++) cout << str[i] << "\n";
  return 0;
}
