#include <bits/stdc++.h>
using namespace std;
string s[10][4];
int x, y;
bool check() {
  for (int i = 3 * x - 2; i <= 3 * x; i++) {
    for (int j = 0; j < 3; j++)
      if (s[i][y][j] == '.') return true;
  }
  return false;
}
int main() {
  for (int i = 1; i <= 9; i++)
    for (int j = 1; j <= 3; j++) cin >> s[i][j];
  cin >> x >> y;
  x %= 3;
  if (!x) x = 3;
  y %= 3;
  if (!y) y = 3;
  if (check()) {
    for (int i = 3 * x - 2; i <= 3 * x; i++) {
      for (int j = 0; j < 3; j++)
        if (s[i][y][j] == '.') s[i][y][j] = '!';
    }
  } else {
    for (int i = 1; i <= 9; i++) {
      for (int j = 1; j <= 3; j++) {
        for (int k = 0; k < 3; k++)
          if (s[i][j][k] == '.') s[i][j][k] = '!';
      }
    }
  }
  for (int i = 1; i <= 9; i++) {
    for (int j = 1; j <= 3; j++) {
      for (int k = 0; k < 3; k++) cout << s[i][j][k];
      cout << " ";
    }
    cout << endl;
    if (i % 3 == 0) cout << endl;
  }
  return 0;
}
