#include <bits/stdc++.h>
using namespace std;
char arra[10][10];
void solve() {
  for (int i = 0; i < 9; i++) {
    for (int j = 0; j < 9; j++) {
      cin >> arra[i][j];
    }
  }
  int m, n;
  cin >> m >> n;
  int x = (m - 1) % 3, y = (n - 1) % 3;
  int khali = 0;
  for (int i = 3 * x; i < 3 * x + 3; i++) {
    for (int j = 3 * y; j < 3 * y + 3; j++) {
      if (arra[i][j] == '.') khali = 1;
    }
  }
  if (khali == 0) {
    for (int i = 0; i < 9; i++) {
      for (int j = 0; j < 9; j++) {
        if (arra[i][j] == '.') arra[i][j] = '!';
      }
    }
  } else {
    for (int i = 3 * x; i < 3 * x + 3; i++) {
      for (int j = 3 * y; j < 3 * y + 3; j++) {
        if (arra[i][j] == '.') arra[i][j] = '!';
      }
    }
  }
  for (int i = 0; i < 9; i++) {
    for (int j = 0; j < 9; j++) {
      cout << arra[i][j];
      if (j % 3 == 2) cout << " ";
    }
    cout << endl;
    if (i % 3 == 2) cout << endl;
  }
}
int main() { solve(); }
