#include <bits/stdc++.h>
using namespace std;
int main() {
  string s[11];
  int x, y, c = 0;
  for (int i = 0; i < 11; i++) getline(cin, s[i]);
  cin >> x >> y;
  x = (x - 1) % 3 + 1, y = (y - 1) % 3 + 1;
  for (int i = 4 * (x - 1); i < 4 * x - 1; i++)
    for (int j = 4 * (y - 1); j < 4 * y - 1; j++)
      if (s[i][j] == '.') c = 1, s[i][j] = '!';
  if (!c)
    for (int i = 0; i < 11; i++)
      for (int j = 0; j < 11; j++) s[i][j] = (s[i][j] == '.') ? '!' : s[i][j];
  for (int i = 0; i < 11; i++) cout << s[i] << "\n";
  return 0;
}
