#include <bits/stdc++.h>
using namespace std;
int dp[50][50];
char pic[50][50];
int x, y;
int main() {
  for (int i = 1; i <= 9; i++) {
    for (int j = 1; j <= 9; j++) {
      cin >> pic[i][j];
      dp[i][j] = ((i % 3 == 0 ? 3 : i % 3) - 1) * 3 + (j % 3 == 0 ? 3 : j % 3);
    }
  }
  cin >> x >> y;
  int pos = dp[x][y];
  bool flag = false;
  if (pos == 1) {
    for (int i = 1; i <= 3; i++) {
      for (int j = 1; j <= 3; j++) {
        if (pic[i][j] == '.') {
          pic[i][j] = '!';
          flag = true;
        }
      }
    }
  }
  if (pos == 2) {
    for (int i = 1; i <= 3; i++) {
      for (int j = 4; j <= 6; j++) {
        if (pic[i][j] == '.') {
          pic[i][j] = '!';
          flag = true;
        }
      }
    }
  }
  if (pos == 3) {
    for (int i = 1; i <= 3; i++) {
      for (int j = 7; j <= 9; j++) {
        if (pic[i][j] == '.') {
          pic[i][j] = '!';
          flag = true;
        }
      }
    }
  }
  if (pos == 4) {
    for (int i = 4; i <= 6; i++) {
      for (int j = 1; j <= 3; j++) {
        if (pic[i][j] == '.') {
          pic[i][j] = '!';
          flag = true;
        }
      }
    }
  }
  if (pos == 5) {
    for (int i = 4; i <= 6; i++) {
      for (int j = 4; j <= 6; j++) {
        if (pic[i][j] == '.') {
          pic[i][j] = '!';
          flag = true;
        }
      }
    }
  }
  if (pos == 6) {
    for (int i = 4; i <= 6; i++) {
      for (int j = 7; j <= 9; j++) {
        if (pic[i][j] == '.') {
          pic[i][j] = '!';
          flag = true;
        }
      }
    }
  }
  if (pos == 7) {
    for (int i = 7; i <= 9; i++) {
      for (int j = 1; j <= 3; j++) {
        if (pic[i][j] == '.') {
          pic[i][j] = '!';
          flag = true;
        }
      }
    }
  }
  if (pos == 8) {
    for (int i = 7; i <= 9; i++) {
      for (int j = 4; j <= 6; j++) {
        if (pic[i][j] == '.') {
          pic[i][j] = '!';
          flag = true;
        }
      }
    }
  }
  if (pos == 9) {
    for (int i = 7; i <= 9; i++) {
      for (int j = 7; j <= 9; j++) {
        if (pic[i][j] == '.') {
          pic[i][j] = '!';
          flag = true;
        }
      }
    }
  }
  if (flag == true) {
    for (int i = 1; i <= 9; i++) {
      for (int j = 1; j <= 9; j++) {
        cout << pic[i][j];
        if (j % 3 == 0) cout << " ";
      }
      cout << endl;
      if (i % 3 == 0) cout << endl;
    }
  } else {
    for (int i = 1; i <= 9; i++) {
      for (int j = 1; j <= 9; j++) {
        if (pic[i][j] == '.') pic[i][j] = '!';
      }
    }
    for (int i = 1; i <= 9; i++) {
      for (int j = 1; j <= 9; j++) {
        cout << pic[i][j];
        if (j % 3 == 0) cout << " ";
      }
      cout << endl;
      if (i % 3 == 0) cout << endl;
    }
  }
}
