#include <bits/stdc++.h>
using namespace std;
int main() {
  vector<vector<string> > tab(9);
  int emp[3][3];
  memset(emp, 0, sizeof emp);
  for (int i = 0; i < 9; i++) {
    tab[i].resize(3);
    for (int j = 0; j < 3; j++) {
      string a;
      cin >> a;
      for (int k = 0; k < a.size(); k++) {
        if (a[k] == '.') emp[i / 3][j]++;
      }
      tab[i][j] = a;
    }
  }
  int n, m;
  cin >> n >> m;
  n--;
  m--;
  char ne;
  int ln = n, lm = (m + 1) % 3;
  if (tab[ln][lm][m % 3] == 'x')
    ne = 'o';
  else
    ne = 'x';
  n = n % 3;
  m = m % 3;
  if (emp[n][m] == 0) {
    for (int i = 0; i < 9; i++) {
      for (int j = 0; j < 3; j++) {
        string a = tab[i][j];
        for (int k = 0; k < 3; k++) {
          if (a[k] == '.') tab[i][j][k] = '!';
        }
      }
    }
  } else {
    for (int i = n * 3; i < (n + 1) * 3; i++) {
      string a = tab[i][m];
      for (int j = 0; j < 3; j++) {
        if (a[j] == '.') tab[i][m][j] = '!';
      }
    }
  }
  for (int i = 0; i < 9; i++) {
    if (i != 0 && i % 3 == 0) cout << endl;
    for (int j = 0; j < 3; j++) {
      cout << tab[i][j] << " ";
    }
    cout << endl;
  }
  return 0;
}
