#include <bits/stdc++.h>
using namespace std;
int b[10][10];
char c[10][4][4];
int main() {
  char ch;
  int x = 1, y = 1, x1, y1, l, z, i, j, r;
  x1 = 3, y1 = 3;
  for (i = 1; i <= 9; ++i) {
    if (i > x1) ++x, x1 += 3;
    y1 = 3;
    y = 1;
    for (j = 1; j <= 9; ++j) {
      if (j % 3 == 0)
        r = 3;
      else
        r = j % 3;
      if (i % 3 == 0)
        l = 3;
      else
        l = i % 3;
      if (j > y1) ++y, y1 += 3;
      cin >> c[x * 3 - (3 - y)][l][r];
    }
  }
  cin >> x >> y;
  if (x % 3 == 0)
    x = 3;
  else
    x %= 3;
  if (y % 3 == 0)
    y = 3;
  else
    y %= 3;
  bool nu = 1;
  for (i = 1; i <= 3 && nu; ++i) {
    for (j = 1; j < 3; ++j) {
      if (c[x * 3 - (3 - y)][i][j] == '.') nu = 0;
    }
  }
  if (nu) {
    x1 = 3, y1 = 3;
    x = y = 1;
    for (i = 1; i <= 9; ++i) {
      if (i > x1) ++x, x1 += 3, cout << "\n";
      y1 = 3;
      y = 1;
      for (j = 1; j <= 9; ++j) {
        if (j % 3 == 0)
          r = 3;
        else
          r = j % 3;
        if (i % 3 == 0)
          l = 3;
        else
          l = i % 3;
        if (j > y1) ++y, y1 += 3, cout << " ";
        if (c[x * 3 - (3 - y)][l][r] == '.')
          cout << "!";
        else
          cout << c[x * 3 - (3 - y)][l][r];
      }
      cout << "\n";
    }
  } else {
    int x3 = x, y3 = y;
    x1 = 3, y1 = 3;
    x = y = 1;
    for (i = 1; i <= 9; ++i) {
      if (i > x1) ++x, x1 += 3, cout << "\n";
      y1 = 3;
      y = 1;
      for (j = 1; j <= 9; ++j) {
        if (j % 3 == 0)
          r = 3;
        else
          r = j % 3;
        if (i % 3 == 0)
          l = 3;
        else
          l = i % 3;
        if (j > y1) ++y, y1 += 3, cout << " ";
        if (x3 == x && y3 == y) {
          if (c[x * 3 - (3 - y)][l][r] == '.')
            cout << "!";
          else
            cout << c[x * 3 - (3 - y)][l][r];
        } else
          cout << c[x * 3 - (3 - y)][l][r];
      }
      cout << "\n";
    }
  }
  return 0;
}
