#include <bits/stdc++.h>
using namespace std;
inline void Boost() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
}
string v[3][3][3];
int main() {
  Boost();
  for (int i = 0; i < 3; ++i) {
    for (int j = 0; j < 3; ++j) {
      for (int k = 0; k < 3; ++k) {
        cin >> v[i][k][j];
      }
    }
  }
  int x, y;
  cin >> x >> y;
  --x;
  --y;
  x %= 3;
  y %= 3;
  bool fre = false;
  for (int i = 0; i < 3; ++i) {
    for (int j = 0; j < 3; ++j) {
      if (v[x][y][i][j] == '.') {
        fre = true;
      }
    }
  }
  if (fre) {
    for (int i = 0; i < 3; ++i) {
      for (int j = 0; j < 3; ++j) {
        if (v[x][y][i][j] == '.') {
          v[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 (v[i][j][k][l] == '.') {
              v[i][j][k][l] = '!';
            }
          }
        }
      }
    }
  }
  for (int j = 0; j < 3; ++j) {
    for (int i = 0; i < 3; ++i) {
      cout << v[j][0][i] << " " << v[j][1][i] << " " << v[j][2][i] << "\n";
    }
    cout << "\n";
  }
  return 0;
}
