#include <bits/stdc++.h>
using namespace std;
char mas[9][9];
int main() {
  for (int i = 0; i < 9; ++i) {
    for (int j = 0; j < 9; ++j) {
      mas[i][j] = '.';
    }
  }
  for (int j = 0; j < 9; ++j) {
    for (int k = 0; k < 9; ++k) {
      char x;
      cin >> x;
      mas[j][k] = x;
    }
  }
  int n, k;
  cin >> n >> k;
  int x, y;
  n--;
  k--;
  x = n % 3;
  y = k % 3;
  bool res = false;
  for (int i = 3 * x; i < 3 * x + 3; ++i) {
    for (int j = 3 * y; j < 3 * y + 3; ++j) {
      if (mas[i][j] == '.') {
        mas[i][j] = '!';
        res = true;
      }
    }
  }
  if (res) {
    for (int i = 0; i < 9; ++i) {
      for (int j = 0; j < 9; ++j) {
        if (j % 3 == 0 && j != 0) {
          cout << " ";
        }
        cout << mas[i][j];
      }
      cout << "\n";
      if ((i + 1) % 3 == 0) {
        cout << "\n";
      }
    }
  } else {
    for (int i = 0; i < 9; ++i) {
      for (int j = 0; j < 9; ++j) {
        if (mas[i][j] == '.') {
          mas[i][j] = '!';
        }
      }
    }
    for (int i = 0; i < 9; ++i) {
      for (int j = 0; j < 9; ++j) {
        if (j % 3 == 0 && j != 0) {
          cout << " ";
        }
        cout << mas[i][j];
      }
      cout << "\n";
      if ((i + 1) % 3 == 0) {
        cout << "\n";
      }
    }
  }
  return 0;
}
