#include <bits/stdc++.h>
using namespace std;
int main() {
  char field[10][10];
  int lastMoveX, lastMoveY, i, j, subfield, checkIfNoMoves = 9;
  for (i = 1; i < 10; i++)
    for (j = 1; j < 10; j++) cin >> field[i][j];
  cin >> lastMoveX >> lastMoveY;
  if (lastMoveX % 3 == 1) {
    if (lastMoveY % 3 == 1)
      subfield = 1;
    else if (lastMoveY % 3 == 2)
      subfield = 2;
    else
      subfield = 3;
  } else if (lastMoveX % 3 == 2) {
    if (lastMoveY % 3 == 1)
      subfield = 4;
    else if (lastMoveY % 3 == 2)
      subfield = 5;
    else
      subfield = 6;
  } else {
    if (lastMoveY % 3 == 1)
      subfield = 7;
    else if (lastMoveY % 3 == 2)
      subfield = 8;
    else
      subfield = 9;
  }
  switch (subfield) {
    case 1:
      for (i = 1; i <= 3; i++) {
        for (j = 1; j <= 3; j++) {
          if (field[i][j] == '.') {
            field[i][j] = '!';
          } else {
            checkIfNoMoves--;
          }
        }
      }
      break;
    case 2:
      for (i = 1; i <= 3; i++) {
        for (j = 4; j <= 6; j++) {
          if (field[i][j] == '.') {
            field[i][j] = '!';
          } else {
            checkIfNoMoves--;
          }
        }
      }
      break;
    case 3:
      for (i = 1; i <= 3; i++) {
        for (j = 7; j <= 9; j++) {
          if (field[i][j] == '.') {
            field[i][j] = '!';
          } else {
            checkIfNoMoves--;
          }
        }
      }
      break;
    case 4:
      for (i = 4; i <= 6; i++) {
        for (j = 1; j <= 3; j++) {
          if (field[i][j] == '.') {
            field[i][j] = '!';
          } else {
            checkIfNoMoves--;
          }
        }
      }
      break;
    case 5:
      for (i = 4; i <= 6; i++) {
        for (j = 4; j <= 6; j++) {
          if (field[i][j] == '.') {
            field[i][j] = '!';
          } else {
            checkIfNoMoves--;
          }
        }
      }
      break;
    case 6:
      for (i = 4; i <= 6; i++) {
        for (j = 7; j <= 9; j++) {
          if (field[i][j] == '.') {
            field[i][j] = '!';
          } else {
            checkIfNoMoves--;
          }
        }
      }
      break;
    case 7:
      for (i = 7; i <= 9; i++) {
        for (j = 1; j <= 3; j++) {
          if (field[i][j] == '.') {
            field[i][j] = '!';
          } else {
            checkIfNoMoves--;
          }
        }
      }
      break;
    case 8:
      for (i = 7; i <= 9; i++) {
        for (j = 4; j <= 6; j++) {
          if (field[i][j] == '.') {
            field[i][j] = '!';
          } else {
            checkIfNoMoves--;
          }
        }
      }
      break;
    case 9:
      for (i = 7; i <= 9; i++) {
        for (j = 7; j <= 9; j++) {
          if (field[i][j] == '.') {
            field[i][j] = '!';
          } else {
            checkIfNoMoves--;
          }
        }
      }
      break;
  }
  if (checkIfNoMoves == 0) {
    for (i = 1; i <= 9; i++) {
      for (j = 1; j <= 9; j++) {
        if (field[i][j] == '.') {
          cout << '!';
        } else {
          cout << field[i][j];
        }
        if (j % 3 == 0) cout << ' ';
      }
      cout << endl;
      if (i % 3 == 0) cout << endl;
    }
  } else {
    for (i = 1; i <= 9; i++) {
      for (j = 1; j <= 9; j++) {
        cout << field[i][j];
        if (j % 3 == 0) cout << ' ';
      }
      cout << endl;
      if (i % 3 == 0) cout << endl;
    }
  }
  return 0;
}
