#include <bits/stdc++.h>
using namespace std;
int main() {
  vector<vector<char>> board(9, vector<char>(9));
  vector<vector<int>> board2(9, vector<int>(9));
  for (int i = 0; i < 9; i++) {
    for (int j = 0; j < 9; j++) {
      board[i][j] = cin.get();
      if (j % 3 == 2) cin.get();
    }
    if (i % 3 == 2 && i != 8) cin.get();
  }
  for (int i = 0; i < 9; i++) {
    for (int j = 0; j < 9; j++) {
      board2[i][j] = i % 3 * 10 + j % 3;
    }
  }
  int x, y;
  x = cin.get() - '0';
  cin.get();
  y = cin.get() - '0';
  int k = board2[x - 1][y - 1];
  int fool = 1;
  for (int i = (k / 10) * 3; i < (k / 10) * 3 + 3; i++) {
    for (int j = k % 10 * 3; j < k % 10 * 3 + 3; j++) {
      if (board[i][j] == '.') {
        fool = 0;
        board[i][j] = '!';
      }
    }
  }
  if (fool) {
    for (int i = 0; i < 9; i++) {
      for (int j = 0; j < 9; j++) {
        if (board[i][j] == '.') {
          board[i][j] = '!';
        }
      }
    }
  }
  for (int i = 0; i < 9; i++) {
    if (i != 0 && i % 3 == 0) {
      cout << '\n';
    }
    for (int j = 0; j < 9; j++) {
      if (j % 3 == 0) cout << ' ';
      cout << board[i][j];
    }
    cout << '\n';
  }
  return 0;
}
