#include <bits/stdc++.h>
const int N = 12;
using namespace std;
int n, x, y, a[N][N];
pair<pair<int, int>, pair<int, int> > b[N] = {
    {{0, 0}, {0, 0}}, {{1, 1}, {3, 3}}, {{1, 4}, {3, 6}}, {{1, 7}, {3, 9}},
    {{4, 1}, {6, 3}}, {{4, 4}, {6, 6}}, {{4, 7}, {6, 9}}, {{7, 1}, {9, 3}},
    {{7, 4}, {9, 6}}, {{7, 7}, {9, 9}}};
int main() {
  ios_base::sync_with_stdio(0);
  n = 9;
  for (int i = 1; i <= n; ++i)
    for (int j = 1; j <= n; ++j) {
      char c;
      cin >> c;
      a[i][j] = (int)c;
    }
  cin >> x >> y;
  x %= 3;
  y %= 3;
  if (x == 0) x = 3;
  if (y == 0) y = 3;
  int flag = 0;
  for (int i = b[(x - 1) * 3 + y].first.first;
       i <= b[(x - 1) * 3 + y].second.first; ++i)
    for (int j = b[(x - 1) * 3 + y].first.second;
         j <= b[(x - 1) * 3 + y].second.second; ++j)
      if (a[i][j] == 46) flag = 1, a[i][j] = 33;
  if (flag == 0) {
    for (int i = 1; i <= n; ++i)
      for (int j = 1; j <= n; ++j)
        if (a[i][j] == 46) a[i][j] = 33;
  }
  for (int i = 1; i <= n; ++i) {
    for (int j = 1; j <= n; ++j) {
      cout << char(a[i][j]);
      if (j % 3 == 0 && j != n) cout << " ";
    }
    cout << "\n";
    if (i % 3 == 0) cout << "\n";
  }
  return 0;
}
