#include <bits/stdc++.h>
using namespace std;
char mat[10][10];
int r1[4] = {1, 4, 7};
int r2[4] = {2, 5, 8};
int r3[4] = {3, 6, 9};
int c1[4] = {1, 4, 7};
int c2[4] = {2, 5, 8};
int c3[4] = {3, 6, 9};
int main() {
  for (int i = 1; i <= 9; i++) {
    for (int j = 1; j <= 9; j++) {
      char ch;
      cin >> ch;
      mat[i][j] = ch;
    }
  }
  int x, y;
  cin >> x >> y;
  int boxx, boxy;
  for (int i = 0; i < 3; i++) {
    if (r1[i] == x) {
      boxx = 1;
    }
    if (r2[i] == x) {
      boxx = 2;
    }
    if (r3[i] == x) {
      boxx = 3;
    }
  }
  for (int i = 0; i < 3; i++) {
    if (c1[i] == y) {
      boxy = 1;
    }
    if (c2[i] == y) {
      boxy = 2;
    }
    if (c3[i] == y) {
      boxy = 3;
    }
  }
  int f = 0;
  if (boxx == 1 && boxy == 1) {
    for (int i = 1; i <= 3; i++) {
      for (int j = 1; j <= 3; j++) {
        if (mat[i][j] == '.') {
          f = 1;
          mat[i][j] = '!';
        }
      }
    }
  }
  if (boxx == 1 && boxy == 2) {
    for (int i = 1; i <= 3; i++) {
      for (int j = 1; j <= 3; j++) {
        if (mat[i][3 + j] == '.') {
          f = 1;
          mat[i][3 + j] = '!';
        }
      }
    }
  }
  if (boxx == 1 && boxy == 3) {
    for (int i = 1; i <= 3; i++) {
      for (int j = 1; j <= 3; j++) {
        if (mat[i][6 + j] == '.') {
          f = 1;
          mat[i][6 + j] = '!';
        }
      }
    }
  }
  if (boxx == 2 && boxy == 1) {
    for (int i = 1; i <= 3; i++) {
      for (int j = 1; j <= 3; j++) {
        if (mat[3 + i][j] == '.') {
          f = 1;
          mat[3 + i][j] = '!';
        }
      }
    }
  }
  if (boxx == 2 && boxy == 2) {
    for (int i = 1; i <= 3; i++) {
      for (int j = 1; j <= 3; j++) {
        if (mat[3 + i][3 + j] == '.') {
          f = 1;
          mat[3 + i][3 + j] = '!';
        }
      }
    }
  }
  if (boxx == 2 && boxy == 3) {
    for (int i = 1; i <= 3; i++) {
      for (int j = 1; j <= 3; j++) {
        if (mat[3 + i][6 + j] == '.') {
          f = 1;
          mat[3 + i][6 + j] = '!';
        }
      }
    }
  }
  if (boxx == 3 && boxy == 1) {
    for (int i = 1; i <= 3; i++) {
      for (int j = 1; j <= 3; j++) {
        if (mat[6 + i][j] == '.') {
          f = 1;
          mat[6 + i][j] = '!';
        }
      }
    }
  }
  if (boxx == 3 && boxy == 2) {
    for (int i = 1; i <= 3; i++) {
      for (int j = 1; j <= 3; j++) {
        if (mat[6 + i][3 + j] == '.') {
          f = 1;
          mat[6 + i][3 + j] = '!';
        }
      }
    }
  }
  if (boxx == 3 && boxy == 3) {
    for (int i = 1; i <= 3; i++) {
      for (int j = 1; j <= 3; j++) {
        if (mat[6 + i][6 + j] == '.') {
          f = 1;
          mat[6 + i][6 + j] = '!';
        }
      }
    }
  }
  if (f == 0) {
    for (int i = 1; i <= 9; i++) {
      for (int j = 1; j <= 9; j++) {
        if (mat[i][j] == '.') {
          mat[i][j] = '!';
        }
      }
    }
  }
  for (int i = 1; i <= 9; i++) {
    for (int j = 1; j <= 9; j++) {
      cout << mat[i][j];
      if (j % 3 == 0) {
        cout << " ";
      }
    }
    if (i % 3 == 0) {
      cout << "\n";
    }
    cout << "\n";
  }
}
