#include <bits/stdc++.h>
using namespace std;
int main() {
  int x, y;
  vector<vector<char>> mat(9, vector<char>(9));
  for (int i = 0; i < 9; i++) {
    for (int j = 0; j < 9; j++) {
      cin >> mat[i][j];
    }
  }
  cin >> x >> y;
  x--;
  y--;
  x %= 3;
  y %= 3;
  int a = x * 3;
  int b = y * 3;
  bool f = true;
  for (int i = a; i < a + 3; i++) {
    for (int j = b; j < b + 3; j++) {
      if (mat[i][j] == '.') {
        f = false;
        mat[i][j] = '!';
      }
    }
  }
  if (f) {
    for (int i = 0; i < 9; i++) {
      for (int j = 0; j < 9; j++) {
        if (mat[i][j] == '.') mat[i][j] = '!';
      }
    }
  }
  for (int i = 0; i < 9; i++) {
    for (int j = 0; j < 9; j++) {
      cout << mat[i][j];
      if (j % 3 == 2) cout << " ";
    }
    cout << "\n";
    if (i % 3 == 2) cout << "\n";
  }
}
