#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  int x1, x2, x3, x4;
  char a[9][9];
  for (int i = 0; i < 9; i++) {
    for (int j = 0; j < 9; j++) {
      cin >> a[i][j];
    }
  }
  cin >> n >> m;
  if (n == 1 || n == 4 || n == 7) {
    x1 = 0;
    x2 = 2;
  }
  if (n == 2 || n == 5 || n == 8) {
    x1 = 3;
    x2 = 5;
  }
  if (n == 3 || n == 6 || n == 9) {
    x1 = 6;
    x2 = 8;
  }
  if (m == 1 || m == 4 || m == 7) {
    x3 = 0;
    x4 = 2;
  }
  if (m == 2 || m == 5 || m == 8) {
    x3 = 3;
    x4 = 5;
  }
  if (m == 3 || m == 6 || m == 9) {
    x3 = 6;
    x4 = 8;
  }
  int k = 0;
  for (int i = x1; i <= x2; i++) {
    for (int j = x3; j <= x4; j++) {
      if (a[i][j] == '.') {
        a[i][j] = '!';
      } else {
        k++;
      }
    }
  }
  if (k == 9) {
    for (int i = 0; i < 9; i++) {
      for (int j = 0; j < 9; j++) {
        if (a[i][j] == '.') {
          cout << '!';
        } else {
          cout << a[i][j];
        }
        if (j == 2 || j == 5 || j == 8) {
          cout << " ";
        }
      }
      cout << endl;
      if (i == 2 || i == 5 || i == 8) {
        cout << endl;
      }
    }
  } else {
    for (int i = 0; i < 9; i++) {
      for (int j = 0; j < 9; j++) {
        cout << a[i][j];
        if (j == 2 || j == 5 || j == 8) {
          cout << " ";
        }
      }
      cout << endl;
      if (i == 2 || i == 5 || i == 8) {
        cout << endl;
      }
    }
  }
  return 0;
}
