#include <bits/stdc++.h>
using namespace std;
int main() {
  string s;
  char table[9][9];
  for (int i = 0; i < 27; i++) {
    cin >> s;
    int start = (i % 3) * 3;
    for (int j = start; j < start + 3; j++) {
      table[i / 3][j] = s[j - start];
    }
  }
  int x, y;
  cin >> x >> y;
  x--;
  y--;
  x = x % 3;
  y = y % 3;
  bool done = false;
  for (int i = x * 3; i < x * 3 + 3; i++) {
    for (int j = y * 3; j < y * 3 + 3; j++) {
      if (table[i][j] == '.') {
        done = true;
        table[i][j] = '!';
      }
    }
  }
  if (!done) {
    for (int i = 0; i < 9; i++) {
      for (int j = 0; j < 9; j++) {
        if (table[i][j] == '.') {
          table[i][j] = '!';
        }
      }
    }
  }
  for (int i = 0; i < 9; i++) {
    for (int j = 0; j < 9; j++) {
      if (j == 2 || j == 5)
        cout << table[i][j] << ' ';
      else if (j == 8)
        cout << table[i][j] << '\n';
      else
        cout << table[i][j];
    }
    if (i == 2 || i == 5) cout << '\n';
  }
  return 0;
}
