#include <bits/stdc++.h>
using namespace std;
int a[9][9];
int main() {
  string s;
  for (int i = 0; i < 9; i++) {
    int co = 0;
    for (int j = 0; j < 3; j++) {
      cin >> s;
      for (int k = 0; k < 3; k++) {
        if (s[k] == 'x') {
          a[i][co] = 1;
        } else if (s[k] == 'o') {
          a[i][co] = -1;
        }
        co++;
      }
    }
  }
  for (int i = 0; i < 9; i++) {
    for (int j = 0; j < 9; j++) {
    }
  }
  int n, m;
  cin >> n >> m;
  n--, m--;
  n = n % 3;
  m = m % 3;
  n = n * 3;
  m = m * 3;
  bool ok = true;
  int co = 0;
  for (int i = n; i < n + 3; i++) {
    for (int j = m; j < m + 3; j++) {
      if (a[i][j] != 0) co++;
    }
  }
  if (co != 9) {
    for (int i = n; i < n + 3; i++) {
      for (int j = m; j < m + 3; j++) {
        if (a[i][j] == 0) a[i][j] = 2;
      }
    }
  } else {
    for (int i = 0; i < 9; i++) {
      for (int j = 0; j < 9; j++) {
        if (a[i][j] == 0) a[i][j] = 2;
      }
    }
  }
  for (int i = 0; i < 9; i++) {
    for (int j = 0; j < 9; j++) {
      if (a[i][j] == -1)
        cout << 'o';
      else if (a[i][j] == 1)
        cout << 'x';
      else if (a[i][j] == 2)
        cout << '!';
      else
        cout << '.';
      if (j % 3 == 2) cout << " ";
    }
    if (i % 3 == 2) cout << endl;
    cout << endl;
  }
}
