#include <bits/stdc++.h>
using namespace std;
char ma[9][9];
int main() {
  for (int i = 0; i < 9; i++)
    for (int j = 0; j < 9; j++) cin >> ma[i][j];
  int i, j;
  cin >> i >> j;
  i--;
  j--;
  i %= 3;
  j %= 3;
  i++;
  j++;
  i *= 3;
  j *= 3;
  bool flag = 0;
  for (int a = i - 1; a > i - 4; a--)
    for (int b = j - 1; b > j - 4; b--) {
      if (ma[a][b] == '.') {
        ma[a][b] = '!';
        flag = 1;
      }
    }
  if (!flag)
    for (int i = 0; i < 9; i++)
      for (int j = 0; j < 9; j++)
        if (ma[i][j] == '.') ma[i][j] = '!';
  for (int i = 0; i < 9; i++) {
    for (int j = 0; j < 9; j++) {
      cout << ma[i][j];
      if ((j + 1) % 3 == 0) cout << " ";
      if (j == 8) cout << endl;
    }
    if ((i + 1) % 3 == 0) cout << endl;
  }
  return 0;
}
