#include <bits/stdc++.h>
using namespace std;
void fast() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
}
int main() {
  long long a, b;
  string s[15];
  string ans[15];
  string t1, t2, t3;
  for (int i = 1; i <= 9; ++i) {
    cin >> t1 >> t2 >> t3;
    s[i] = t1 + t2 + t3;
  }
  cin >> a >> b;
  long long kor1, kor2;
  if (a % 3 == 1) kor1 = 0;
  if (a % 3 == 2) kor1 = 1;
  if (a % 3 == 0) kor1 = 2;
  long long kor3, kor4;
  if (b % 3 == 1) kor2 = 0;
  if (b % 3 == 2) kor2 = 1;
  if (b % 3 == 0) kor2 = 2;
  long long sum = 0;
  for (int i = 1; i <= 9; ++i) {
    for (int j = 0; j < 9; ++j) {
      if ((i - 1) / 3 == 0) kor3 = 0;
      if ((i - 1) / 3 == 1) kor3 = 1;
      if ((i - 1) / 3 == 2) kor3 = 2;
      if (j / 3 == 0) kor4 = 0;
      if (j / 3 == 1) kor4 = 1;
      if (j / 3 == 2) kor4 = 2;
      if (kor3 == kor1 && kor2 == kor4 && s[i][j] == '.') {
        s[i][j] = '!';
        sum++;
      }
    }
  }
  if (!sum) {
    for (int i = 1; i <= 9; ++i) {
      for (int j = 0; j < 9; ++j) {
        if (s[i][j] == '.') s[i][j] = '!';
        cout << s[i][j];
        if ((j + 1) % 3 == 0) cout << " ";
      }
      if (i % 3 == 0) cout << "\n";
      cout << "\n";
    }
  } else {
    for (int i = 1; i <= 9; ++i) {
      for (int j = 0; j < 9; ++j) {
        cout << s[i][j];
        if ((j + 1) % 3 == 0) cout << " ";
      }
      if (i % 3 == 0) cout << "\n";
      cout << "\n";
    }
  }
  return 0;
}
