#include <bits/stdc++.h>
using namespace std;
int main() {
  char v[10][10];
  for (int i = 0; i < 9; i++) {
    for (int j = 0; j < 9; j++) {
      cin >> v[i][j];
    }
  }
  int n, m;
  cin >> n >> m;
  n, m;
  bool fla = false;
  int i, j;
  if (n % 3 == 0)
    i = 6;
  else if (n % 3 == 1)
    i = 0;
  else if (n % 3 == 2)
    i = 3;
  if (m % 3 == 0)
    j = 6;
  else if (m % 3 == 1)
    j = 0;
  else if (m % 3 == 2)
    j = 3;
  int r = i, r2 = j;
  for (int i = r; i < r + 3; i++)
    for (int j = r2; j < r2 + 3; j++) {
      if (v[i][j] == '.') {
        fla = true;
        break;
      }
    }
  n, m;
  if (n % 3 == 0)
    i = 6;
  else if (n % 3 == 1)
    i = 0;
  else if (n % 3 == 2)
    i = 3;
  if (m % 3 == 0)
    j = 6;
  else if (m % 3 == 1)
    j = 0;
  else if (m % 3 == 2)
    j = 3;
  r = i, r2 = j;
  if (fla) {
    for (i = r; i < r + 3; i++)
      for (j = r2; j < r2 + 3; j++) {
        if (v[i][j] == '.') v[i][j] = '!';
      }
  } else {
    for (int i = 0; i < 9; i++)
      for (int j = 0; j < 9; j++) {
        if (v[i][j] == '.') {
          v[i][j] = '!';
        }
      }
  }
  for (int i = 0; i < 9; i++) {
    for (int j = 0; j < 9; j++) {
      cout << v[i][j];
      if (j == 2 || j == 5) cout << " ";
    }
    cout << endl;
    if (i == 2 || i == 5) cout << endl;
  }
}
