#include <bits/stdc++.h>
using namespace std;
int main() {
  char x[11][11];
  for (int i = 0; i < 11; i++) {
    if (i == 3 || i == 7) {
      for (int j = 0; j < 11; j++) x[i][j] = ' ';
      continue;
    }
    for (int j = 0; j < 11; j++) {
      if (j == 3 || j == 7) {
        x[i][j] = ' ';
        continue;
      }
      cin >> x[i][j];
    }
  }
  int f, y;
  cin >> f >> y;
  int r, c;
  if (f == 1 || f == 4 || f == 7)
    r = 1;
  else if (f == 2 || f == 5 || f == 8)
    r = 2;
  else if (f == 3 || f == 6 || f == 9)
    r = 3;
  if (y == 1 || y == 4 || y == 7)
    c = 1;
  else if (y == 2 || y == 5 || y == 8)
    c = 2;
  else if (y == 3 || y == 6 || y == 9)
    c = 3;
  if (r == 1)
    r = 0;
  else if (r == 2)
    r = 4;
  else if (r == 3)
    r = 8;
  if (c == 1)
    c = 0;
  else if (c == 2)
    c = 4;
  else if (c == 3)
    c = 8;
  bool lo = true;
  for (int i = r; i < r + 3; i++) {
    for (int j = c; j < c + 3; j++) {
      if (x[i][j] == '.') {
        lo = false;
        x[i][j] = '!';
      }
    }
  }
  if (lo) {
    for (int i = 0; i < 11; i++) {
      for (int j = 0; j < 11; j++) {
        if (x[i][j] == '.') x[i][j] = '!';
      }
    }
  }
  for (int i = 0; i < 11; i++) {
    for (int j = 0; j < 11; j++) {
      cout << x[i][j];
    }
    cout << endl;
  }
  return 0;
}
