#include <bits/stdc++.h>
using namespace std;
int main() {
  char **A = new char *[9];
  for (int i = 0; i < 9; i++) A[i] = new char[9];
  for (int i = 0; i < 9; i++)
    for (int j = 0; j < 9; j++) cin >> A[i][j];
  int x, y;
  cin >> y >> x;
  x--;
  y--;
  bool Flag = true;
  pair<int, int> T2;
  if ((x == 0 || x == 3 || x == 6) && (y == 0 || y == 3 || y == 6)) {
    T2.first = 0;
    T2.second = 0;
  } else if ((x == 1 || x == 4 || x == 7) && (y == 1 || y == 4 || y == 7)) {
    T2.first = 3;
    T2.second = 3;
  } else if ((x == 2 || x == 5 || x == 8) && (y == 2 || y == 5 || y == 8)) {
    T2.first = 6;
    T2.second = 6;
  } else if ((x == 1 || x == 4 || x == 7) && (y == 0 || y == 3 || y == 6)) {
    T2.first = 0;
    T2.second = 3;
  } else if ((x == 2 || x == 5 || x == 8) && (y == 0 || y == 3 || y == 6)) {
    T2.first = 0;
    T2.second = 6;
  } else if ((x == 0 || x == 3 || x == 6) && (y == 1 || y == 4 || y == 7)) {
    T2.first = 3;
    T2.second = 0;
  } else if ((x == 0 || x == 3 || x == 6) && (y == 2 || y == 5 || y == 8)) {
    T2.first = 6;
    T2.second = 0;
  } else if ((x == 2 || x == 5 || x == 8) && (y == 1 || y == 4 || y == 7)) {
    T2.first = 3;
    T2.second = 6;
  } else if ((x == 1 || x == 4 || x == 7) && (y == 2 || y == 5 || y == 8)) {
    T2.first = 6;
    T2.second = 3;
  }
  for (int i = T2.first; i < T2.first + 3; i++) {
    for (int j = T2.second; j < T2.second + 3; j++)
      if (A[i][j] == '.') {
        A[i][j] = '!';
        Flag = false;
      }
  }
  if (Flag) {
    for (int i = 0; i < 9; i++)
      for (int j = 0; j < 9; j++)
        if (A[i][j] == '.') A[i][j] = '!';
  }
  for (int i = 0; i < 9; i++) {
    for (int j = 0; j < 9; j++) {
      cout << A[i][j];
      if (j == 2 || j == 5) cout << " ";
    }
    if (i != 2 && i != 5)
      cout << endl;
    else
      cout << endl << endl;
  }
}
