#include <bits/stdc++.h>
using namespace std;
int main() {
  long long i, j, k, m, n, t;
  string arr[12];
  for (i = 0; i < 11; i++) {
    getline(cin, arr[i]);
  }
  long long x, y;
  cin >> x >> y;
  long long x1, y1;
  long long x2 = x % 3;
  long long y2 = y % 3;
  if (x2 == 1) {
    if (y2 == 1) {
      x1 = 0;
      y1 = 0;
    } else if (y2 == 2) {
      x1 = 0;
      y1 = 4;
    } else if (y2 == 0) {
      x1 = 0;
      y1 = 8;
    }
  } else if (x2 == 2) {
    if (y2 == 1) {
      x1 = 4;
      y1 = 0;
    } else if (y2 == 2) {
      x1 = 4;
      y1 = 4;
    } else if (y2 == 0) {
      x1 = 4;
      y1 = 8;
    }
  } else if (x2 == 0) {
    if (y2 == 1) {
      x1 = 8;
      y1 = 0;
    } else if (y2 == 2) {
      x1 = 8;
      y1 = 4;
    } else if (y2 == 0) {
      x1 = 8;
      y1 = 8;
    }
  }
  long long f = 0;
  for (i = x1; i < x1 + 3; i++) {
    for (j = y1; j < y1 + 3; j++) {
      if (arr[i][j] == '.') {
        arr[i][j] = '!';
        f = 1;
      }
    }
  }
  for (i = 0; i < 11; i++) {
    for (j = 0; j < 11; j++) {
      if (f == 0) {
        if (arr[i][j] == '.') {
          cout << '!';
        } else {
          if (i == 3 || i == 7 || j == 3 || j == 7) {
            cout << " ";
          } else
            cout << arr[i][j];
        }
      } else {
        if (i == 3 || i == 7 || j == 3 || j == 7) {
          cout << " ";
        } else
          cout << arr[i][j];
      }
    }
    cout << '\n';
  }
  return 0;
}
