#include <bits/stdc++.h>
using namespace std;
int X, Y;
char grid[9][9];
bool all_filled(int x, int y) {
  for (int i = 3 * x; i <= 3 * x + 2; i++)
    for (int j = 3 * y; j <= 3 * y + 2; j++)
      if (grid[i][j] == '.') return false;
  return true;
}
int main() {
  ios::sync_with_stdio(0);
  for (int i = 0; i < 9; i++) {
    string s1, s2, s3;
    cin >> s1 >> s2 >> s3;
    string s = s1 + s2 + s3;
    for (int j = 0; j < 9; j++) grid[i][j] = s[j];
  }
  cin >> X >> Y;
  X--, Y--;
  X %= 3, Y %= 3;
  if (all_filled(X, Y)) {
    for (int i = 0; i < 9; i++)
      for (int j = 0; j < 9; j++)
        if (grid[i][j] == '.') grid[i][j] = '!';
  } else {
    for (int i = 3 * X; i <= 3 * X + 2; i++)
      for (int j = 3 * Y; j <= 3 * Y + 2; j++)
        if (grid[i][j] == '.') grid[i][j] = '!';
  }
  for (int i = 0; i < 9; i++) {
    for (int j = 0; j < 9; j++) {
      cout << grid[i][j];
      if (j % 3 == 2) cout << " ";
    }
    cout << "\n";
    if (i % 3 == 2) cout << "\n";
  }
  return 0;
}
