#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(false);
  char mat[9][9];
  for (int i = 0; i < 9; i++) {
    for (int j = 0; j < 9; j++) {
      cin >> mat[i][j];
    }
  }
  int a, b;
  cin >> a >> b;
  a--;
  b--;
  int A = a % 3;
  int B = b % 3;
  bool full = true;
  for (int i = 3 * A; i < 3 * A + 3; i++) {
    for (int j = 3 * B; j < 3 * B + 3; j++) {
      if (mat[i][j] == '.') {
        full = false;
        mat[i][j] = '!';
      }
    }
  }
  for (int i = 0; i < 9; i++) {
    for (int j = 0; j < 9; j++) {
      if (full && mat[i][j] == '.') mat[i][j] = '!';
      cout << mat[i][j];
      if (j % 3 == 2) cout << " ";
    }
    cout << endl;
    if (i % 3 == 2) cout << endl;
  }
}
