#include <bits/stdc++.h>
using namespace std;
const int N = 1000007;
const int inf = 0x3f3f3f3f;
vector<string> mat;
int main() {
  ios::sync_with_stdio(false);
  string s;
  for (int i = 0; i < 3; i++) {
    getline(cin, s);
    string t = "";
    for (int j = 0; j < s.size(); j++) {
      if (s[j] != ' ') t += s[j];
    }
    mat.push_back(t);
  }
  getline(cin, s);
  for (int i = 0; i < 3; i++) {
    getline(cin, s);
    string t = "";
    for (int j = 0; j < s.size(); j++) {
      if (s[j] != ' ') t += s[j];
    }
    mat.push_back(t);
  }
  getline(cin, s);
  for (int i = 0; i < 3; i++) {
    getline(cin, s);
    string t = "";
    for (int j = 0; j < s.size(); j++) {
      if (s[j] != ' ') t += s[j];
    }
    mat.push_back(t);
  }
  int x, y;
  cin >> x >> y;
  int i, j;
  switch (x % 3) {
    case 1:
      i = 0;
      break;
    case 2:
      i = 3;
      break;
    case 0:
      i = 6;
      break;
  }
  switch (y % 3) {
    case 1:
      j = 0;
      break;
    case 2:
      j = 3;
      break;
    case 0:
      j = 6;
      break;
  }
  int aux = j;
  bool ok = false;
  for (int k = 0; k < 3; k++) {
    for (int l = 0; l < 3; l++) {
      if (mat[i][j] == '.') {
        ok = true;
        mat[i][j] = '!';
      }
      j++;
    }
    i++;
    j = aux;
  }
  if (!ok) {
    for (int k = 0; k < 9; k++) {
      for (int l = 0; l < mat[k].size(); l++) {
        if (mat[k][l] == '.') mat[k][l] = '!';
      }
    }
  }
  for (int k = 0; k < 9; k++) {
    for (int l = 0; l < mat[k].size(); l++) {
      cout << mat[k][l];
      if (l % 3 == 2) cout << " ";
    }
    cout << endl;
    if (k % 3 == 2) cout << endl;
  }
  return 0;
}
