#include <bits/stdc++.h>
using namespace std;
int bucatal, bucatac;
string s[20];
bool nuefull() {
  for (int i = bucatal; i < bucatal + 3; ++i) {
    for (int j = bucatac; j < bucatac + 3; ++j) {
      if (s[i][j] == '.') {
        return true;
      }
    }
  }
  return false;
}
int main() {
  int l, c;
  for (int i = 0; i < 11; ++i) {
    getline(cin, s[i]);
  }
  cin >> l >> c;
  l %= 3;
  c %= 3;
  if (l == 0) {
    bucatal = 8;
  } else if (l == 1) {
    bucatal = 0;
  } else {
    bucatal = 4;
  }
  if (c == 0) {
    bucatac = 8;
  } else if (c == 1) {
    bucatac = 0;
  } else {
    bucatac = 4;
  }
  if (nuefull()) {
    for (int i = 0; i < 11; ++i) {
      if (i == 3 || i == 7) {
        cout << "\n";
        continue;
      }
      for (int j = 0; j < 11; ++j) {
        if (i >= bucatal && i < bucatal + 3 && j >= bucatac &&
            j < bucatac + 3 && s[i][j] == '.') {
          cout << '!';
        } else {
          cout << s[i][j];
        }
      }
      cout << "\n";
    }
  } else {
    for (int i = 0; i < 11; ++i) {
      if (i == 3 || i == 7) {
        cout << "\n";
        continue;
      }
      for (int j = 0; j < 11; ++j) {
        if (s[i][j] == '.') {
          cout << '!';
        } else {
          cout << s[i][j];
        }
      }
      cout << "\n";
    }
  }
  return 0;
}
