#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(0);
  char board[9][9];
  char trash;
  for (long r = 0; r < 3; ++r) {
    for (long x = 0; x < 3; ++x) {
      for (long c = 0; c < 3; ++c) {
        for (long y = 0; y < 3; ++y) cin >> board[3 * r + x][3 * c + y];
        if (c == 5) cin >> trash;
      }
    }
  }
  long x, y;
  cin >> x >> y;
  --x, --y;
  x %= 3;
  y %= 3;
  bool empty = false;
  for (long i = 0; i < 3; ++i)
    for (long j = 0; j < 3; ++j)
      if (board[3 * x + i][3 * y + j] == '.') empty = true;
  if (empty) {
    for (long i = 0; i < 3; ++i)
      for (long j = 0; j < 3; ++j)
        if (board[3 * x + i][3 * y + j] == '.')
          board[3 * x + i][3 * y + j] = '!';
  } else {
    for (long i = 0; i < 9; ++i)
      for (long j = 0; j < 9; ++j)
        if (board[i][j] == '.') board[i][j] = '!';
  }
  for (long r = 0; r < 3; ++r) {
    for (long x = 0; x < 3; ++x) {
      for (long c = 0; c < 3; ++c) {
        for (long y = 0; y < 3; ++y) cout << board[3 * r + x][3 * c + y];
        if (c < 2) cout << ' ';
      }
      cout << "\n";
    }
    cout << "\n";
  }
}
