#include <bits/stdc++.h>
using namespace std;
string s[10][10][10];
bool done[10][10];
int main() {
  for (int i = 0; i < 3; i++) {
    for (int k = 0; k < 3; k++) {
      for (int j = 0; j < 3; j++) {
        cin >> s[i][j][k];
        for (int z = 0; z < 3; z++) {
          if (s[i][j][k][z] == '.') done[i][j] = 1;
        }
      }
    }
  }
  int x, y;
  cin >> x >> y;
  if (x % 3 == 1)
    x = 0;
  else if (x % 3 == 2)
    x = 1;
  else if (x % 3 == 0)
    x = 2;
  if (y % 3 == 1)
    y = 0;
  else if (y % 3 == 2)
    y = 1;
  else if (y % 3 == 0)
    y = 2;
  if (done[x][y]) {
    for (int i = 0; i < 3; i++) {
      for (int j = 0; j < 3; j++) {
        if (s[x][y][i][j] == '.') s[x][y][i][j] = '!';
      }
    }
  } else {
    for (int i = 0; i < 3; i++) {
      for (int j = 0; j < 3; j++) {
        for (int k = 0; k < 3; k++) {
          for (int l = 0; l < 3; l++) {
            if (s[i][j][k][l] == '.') s[i][j][k][l] = '!';
          }
        }
      }
    }
  }
  for (int i = 0; i < 3; i++) {
    for (int k = 0; k < 3; k++) {
      for (int j = 0; j < 3; j++) {
        cout << s[i][j][k] << " ";
      }
      cout << endl;
    }
    cout << endl;
  }
}
