#include <bits/stdc++.h>
using namespace std;
int main() {
  int x, y;
  string a[9][3];
  for (int i = 0; i < 9; i++)
    for (int j = 0; j < 3; j++) cin >> a[i][j];
  cin >> x >> y;
  x = (x - 1) % 3;
  y = (y - 1) % 3;
  bool empty = 0;
  for (int i = 0; i < 3; ++i) {
    for (int j = 0; j < 3; ++j) {
      if (a[3 * x + i][y][j] == '.') {
        empty = 1;
        a[3 * x + i][y][j] = '!';
      }
    }
  }
  if (!empty)
    for (int i = 0; i < 9; ++i)
      for (int j = 0; j < 3; ++j)
        for (int k = 0; k < 3; ++k)
          if (a[i][j][k] == '.') a[i][j][k] = '!';
  for (int i = 0; i < 9; i++) {
    for (int j = 0; j < 3; j++) cout << a[i][j] << ' ';
    cout << endl;
    if ((i + 1) % 3 == 0) cout << endl;
  }
}
