#include <bits/stdc++.h>
using namespace std;
string arr[4][4][4];
int main() {
  for (int i = 0; i < 3; ++i) {
    for (int k = 0; k < 3; ++k)
      for (int j = 0; j < 3; ++j) cin >> arr[i][j][k];
  }
  int x, y;
  cin >> x >> y;
  x--, y--;
  int a = x % 3;
  int b = y % 3;
  bool flag = 0;
  for (int i = 0; i < 3; ++i)
    for (int j = 0; j < 3; ++j) {
      flag |= (arr[a][b][i][j] == '.');
    }
  if (flag) {
    for (int i = 0; i < 3; ++i)
      for (int j = 0; j < 3; ++j) {
        if (arr[a][b][i][j] == '.') arr[a][b][i][j] = '!';
      }
  } else {
    for (int i = 0; i < 3; ++i) {
      for (int k = 0; k < 3; ++k)
        for (int j = 0; j < 3; ++j)
          for (int a = 0; a < 3; ++a)
            if (arr[i][j][k][a] == '.') arr[i][j][k][a] = '!';
    }
  }
  for (int i = 0; i < 3; ++i) {
    for (int k = 0; k < 3; ++k)
      for (int j = 0; j < 3; ++j) {
        cout << arr[i][j][k] << " \n"[j == 2];
      }
    cout << endl;
  }
  return 0;
}
