#include <bits/stdc++.h>
using namespace std;
int main() {
  char m[15][15];
  for (int i = int(0); i < int(11); i++) gets(m[i]);
  for (int i = int(4); i < int(7); i++) {
    strcpy(m[i - 1], m[i]);
  }
  for (int i = int(8); i < int(11); i++) {
    strcpy(m[i - 2], m[i]);
  }
  for (int i = int(0); i < int(9); i++) {
    for (int j = int(4); j < int(7); j++) {
      m[i][j - 1] = m[i][j];
    }
  }
  for (int i = int(0); i < int(9); i++) {
    for (int j = int(8); j < int(11); j++) {
      m[i][j - 2] = m[i][j];
    }
  }
  int x, y;
  cin >> x >> y;
  --x;
  --y;
  x = x % 3;
  y = y % 3;
  x *= 3;
  y *= 3;
  bool fu = 1;
  for (int i = int(x); i < int(x + 3); i++)
    for (int j = int(y); j < int(y + 3); j++) {
      if (m[i][j] == '.') fu = 0;
    }
  if (!fu) {
    for (int i = int(x); i < int(x + 3); i++)
      for (int j = int(y); j < int(y + 3); j++) {
        if (m[i][j] == '.') m[i][j] = '!';
      }
  } else {
    for (int i = int(0); i < int(9); i++)
      for (int j = int(0); j < int(9); j++)
        if (m[i][j] == '.') m[i][j] = '!';
  }
  for (int i = int(0); i < int(9); i++) {
    for (int j = int(0); j < int(9); j++) {
      if (j == 3 || j == 6) cout << " ";
      cout << m[i][j];
    }
    if (i == 2 || i == 5) cout << endl;
    cout << endl;
  }
  return 0;
}
