#include <bits/stdc++.h>
using namespace std;
char arr[10][10];
int x[] = {7, 1, 4};
int y[] = {7, 1, 4};
int main() {
  for (int i = 1; i <= 9; ++i) {
    for (int j = 1; j <= 9; ++j) {
      cin >> arr[i][j];
    }
  }
  int a, b;
  cin >> a >> b;
  int aa = x[a % 3], bb = y[b % 3];
  bool OK = false;
  for (int i = aa; i <= aa + 2 && !OK; ++i) {
    for (int j = bb; j <= bb + 2; ++j) {
      if (arr[i][j] == '.') {
        OK = true;
        break;
      }
    }
  }
  if (OK) {
    for (int i = aa; i <= aa + 2; ++i) {
      for (int j = bb; j <= bb + 2; ++j) {
        if (arr[i][j] == '.') arr[i][j] = '!';
      }
    }
    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';
    }
  } else {
    for (int i = 1; i <= 9; ++i) {
      for (int j = 1; j <= 9; ++j) {
        if (arr[i][j] == '.')
          cout << '!';
        else
          cout << arr[i][j];
        if (j % 3 == 0) cout << ' ';
      }
      cout << '\n';
      if (i % 3 == 0) cout << '\n';
    }
  }
}
