#include <bits/stdc++.h>
using namespace std;
int main() {
  char A[3][3][3][3];
  for (int i = 0; i < 3; i++) {
    for (int k = 0; k < 3; k++) {
      for (int j = 0; j < 9; j++) {
        cin >> A[i][j / 3][k][j % 3];
      }
    }
  }
  int n, m;
  cin >> n >> m;
  n--;
  int n1 = n % 3;
  m--;
  int m1 = m % 3;
  int free = 0;
  for (int i = 0; i < 3; i++) {
    for (int j = 0; j < 3; j++) {
      if (A[n1][m1][i][j] == '.') {
        free = 1;
        A[n1][m1][i][j] = '!';
      }
    }
  }
  if (!free) {
    for (int i = 0; i < 3; i++) {
      for (int k = 0; k < 3; k++) {
        for (int j = 0; j < 9; j++) {
          if (A[i][j / 3][k][j % 3] == '.') {
            A[i][j / 3][k][j % 3] = '!';
          }
        }
      }
    }
  }
  for (int i = 0; i < 3; i++) {
    for (int k = 0; k < 3; k++) {
      for (int j = 0; j < 9; j++) {
        cout << A[i][j / 3][k][j % 3];
        if (j % 3 == 2) {
          char c;
          cout << " ";
        }
      }
      cout << endl;
    }
    cout << endl;
  }
  return 0;
}
