#include <bits/stdc++.h>
using namespace std;
int ar[10];
int main() {
  int64_t a, b, c, d, e, f[9], m1, m2, m3, n1, n2, n3;
  char p[10][10], q;
  for (int i = 0; i < 9; i++) {
    for (int j = 0; j < 9; j++) {
      cin >> p[i][j];
      if (p[i][j] == '.') ar[((i / 3) * 3 + (j) / 3)]++;
    }
  }
  cin >> a >> b;
  c = a % 3;
  c += (c == 0) * 3;
  d = b % 3;
  d += (d == 0) * 3;
  if (ar[(c - 1) * 3 + (d - 1)] == 0)
    for (int i = 0; i < 9; i++) {
      for (int j = 0; j < 9; j++) {
        if (j % 3 == 0 && j != 0) cout << ' ';
        if (p[i][j] == '.')
          cout << '!';
        else
          cout << p[i][j];
      }
      cout << "\n";
      if ((i + 1) % 3 == 0) cout << "\n";
    }
  else {
    for (int i = 3 * (c - 1); i < 3 * c; i++)
      for (int j = 3 * (d - 1); j < 3 * d; j++)
        if (p[i][j] == '.') p[i][j] = '!';
    for (int i = 0; i < 9; i++) {
      for (int j = 0; j < 9; j++) {
        if (j % 3 == 0 && j != 0) cout << " ";
        cout << p[i][j];
      }
      if ((i + 1) % 3 == 0) cout << "\n";
      cout << "\n";
    }
  }
}
