#include <bits/stdc++.h>
using namespace std;
char arr[100][100];
void print() {
  for (int i = 1; i <= 9; i++) {
    for (int j = 1; j <= 9; j++) {
      cout << arr[i][j];
      if (j % 3 == 0) cout << ' ';
    }
    cout << "\n";
    if (i % 3 == 0) cout << "\n";
  }
}
int main() {
  int x, y;
  int tx[] = {0, 1, 4, 7, 1, 4, 7, 1, 4, 7};
  for (int i = 1; i <= 9; i++) {
    for (int j = 1; j <= 9; j++) {
      cin >> arr[i][j];
    }
  }
  cin >> x >> y;
  bool flag = 0;
  int row = tx[x], col = tx[y];
  for (int i = row; i < row + 3; i++) {
    for (int j = col; j < col + 3; j++) {
      if (arr[i][j] == '.') {
        flag = 1;
        arr[i][j] = '!';
      }
    }
  }
  if (flag) {
    print();
    return 0;
  }
  for (int i = 1; i <= 9; i++) {
    for (int j = 1; j <= 9; j++) {
      if (arr[i][j] == '.') arr[i][j] = '!';
    }
  }
  print();
  return 0;
}
