#include <bits/stdc++.h>
using namespace std;
string s;
int a[3][3][3][3], c[3][3][3][3];
int main() {
  for (int i = 0; i <= 2; i++) {
    for (int x = 0; x <= 2; x++) {
      for (int j = 0; j <= 2; j++) {
        cin >> s;
        for (int y = 0; y <= 2; y++) {
          a[i][j][x][y] = s[y] == '.' ? 0 : 1;
          c[i][j][x][y] = s[y];
        }
      }
    }
  }
  int i, j;
  cin >> i >> j;
  if (i % 3 == 0)
    i = 2;
  else
    i = i % 3 - 1;
  if (j % 3 == 0)
    j = 2;
  else
    j = j % 3 - 1;
  bool ok = true;
  for (int x = 0; x <= 2; x++)
    for (int y = 0; y <= 2; y++)
      if (a[i][j][x][y] == 0) ok = false;
  if (ok) {
    for (int i = 0; i <= 2; i++) {
      for (int x = 0; x <= 2; x++) {
        for (int j = 0; j <= 2; j++) {
          for (int y = 0; y <= 2; y++) {
            if (c[i][j][x][y] != '.')
              cout << (char)c[i][j][x][y];
            else
              cout << '!';
          }
          cout << " ";
        }
        cout << endl;
      }
      cout << endl;
    }
  } else {
    for (int x = 0; x <= 2; x++)
      for (int y = 0; y <= 2; y++)
        if (c[i][j][x][y] == '.') c[i][j][x][y] = '!';
    for (int i = 0; i <= 2; i++) {
      for (int x = 0; x <= 2; x++) {
        for (int j = 0; j <= 2; j++) {
          for (int y = 0; y <= 2; y++) cout << (char)c[i][j][x][y];
          cout << " ";
        }
        cout << endl;
      }
      cout << endl;
    }
  }
  return 0;
}
