#include <bits/stdc++.h>
using namespace std;
int main() {
  char m[9][9];
  for (int i = 0; i < 9; i++) {
    for (int j = 0; j < 9;) {
      char c = getchar();
      if (c != ' ') {
        m[i][j] = c;
        j++;
      }
    }
    getchar();
    if (i == 2 || i == 5) getchar();
  }
  int x, y;
  cin >> x >> y;
  x--;
  y--;
  x = x % 3;
  y = y % 3;
  bool full[3][3];
  for (int i = 0; i < 3; i++) {
    for (int l = 0; l < 3; l++) {
      int cont = 0;
      for (int j = 0; j < 3; j++) {
        int xx = j + i * 3;
        for (int k = 0; k < 3; k++) {
          int yy = k + l * 3;
          if (m[xx][yy] != '.') {
            cont++;
          }
        }
      }
      if (cont == 9) {
        full[i][l] = true;
      } else {
        full[i][l] = false;
      }
    }
  }
  if (full[x][y]) {
    for (int i = 0; i < 3; i++) {
      for (int l = 0; l < 3; l++) {
        int cont = 0;
        for (int j = 0; j < 3; j++) {
          int xx = j + i * 3;
          for (int k = 0; k < 3; k++) {
            int yy = k + l * 3;
            if (m[xx][yy] == '.') {
              m[xx][yy] = '!';
            }
          }
        }
      }
    }
  } else {
    for (int i = 0; i < 3; i++) {
      for (int l = 0; l < 3; l++) {
        int cont = 0;
        for (int j = 0; j < 3; j++) {
          int xx = j + i * 3;
          for (int k = 0; k < 3; k++) {
            int yy = k + l * 3;
            if (i == x && l == y && m[xx][yy] == '.') {
              m[xx][yy] = '!';
            }
          }
        }
      }
    }
  }
  for (int i = 0; i < 9; i++) {
    for (int j = 0; j < 9; j++) {
      cout << m[i][j];
      if (j == 2 || j == 5) cout << ' ';
    }
    cout << endl;
    if (i == 2 || i == 5) cout << endl;
  }
  return 0;
}
