#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 77;
const int MOD = 1e9 + 7;
int n, m;
char t[4][4][4][4];
bool filled(int nx, int ny) {
  for (int i = 1; i <= 3; i++) {
    for (int j = 1; j <= 3; j++) {
      if (t[nx][ny][i][j] == '.') return false;
    }
  }
  return true;
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  for (int i = 1; i <= 3; i++) {
    for (int j = 1; j <= 3; j++) {
      cin >> t[1][1][i][j];
    }
    for (int j = 1; j <= 3; j++) {
      cin >> t[1][2][i][j];
    }
    for (int j = 1; j <= 3; j++) {
      cin >> t[1][3][i][j];
    }
  }
  for (int i = 1; i <= 3; i++) {
    for (int j = 1; j <= 3; j++) {
      cin >> t[2][1][i][j];
    }
    for (int j = 1; j <= 3; j++) {
      cin >> t[2][2][i][j];
    }
    for (int j = 1; j <= 3; j++) {
      cin >> t[2][3][i][j];
    }
  }
  for (int i = 1; i <= 3; i++) {
    for (int j = 1; j <= 3; j++) {
      cin >> t[3][1][i][j];
    }
    for (int j = 1; j <= 3; j++) {
      cin >> t[3][2][i][j];
    }
    for (int j = 1; j <= 3; j++) {
      cin >> t[3][3][i][j];
    }
  }
  int r, c;
  cin >> r >> c;
  int row = ((r - 1) / 3) + 1;
  int col = ((c - 1) / 2) + 1;
  int x = (r - 1) % 3 + 1;
  int y = (c - 1) % 3 + 1;
  if (filled(x, y)) {
    for (int i = 1; i <= 3; i++) {
      for (int j = 1; j <= 3; j++) {
        for (int p = 1; p <= 3; p++) {
          for (int m = 1; m <= 3; m++) {
            if (t[m][p][i][j] == '.') t[m][p][i][j] = '!';
          }
        }
      }
    }
  } else {
    for (int i = 1; i <= 3; i++) {
      for (int j = 1; j <= 3; j++) {
        if (t[x][y][i][j] == '.') t[x][y][i][j] = '!';
      }
    }
  }
  for (int i = 1; i <= 3; i++) {
    for (int j = 1; j <= 3; j++) {
      cout << t[1][1][i][j];
    }
    cout << ' ';
    for (int j = 1; j <= 3; j++) {
      cout << t[1][2][i][j];
    }
    cout << ' ';
    for (int j = 1; j <= 3; j++) {
      cout << t[1][3][i][j];
    }
    cout << '\n';
  }
  cout << '\n';
  for (int i = 1; i <= 3; i++) {
    for (int j = 1; j <= 3; j++) {
      cout << t[2][1][i][j];
    }
    cout << ' ';
    for (int j = 1; j <= 3; j++) {
      cout << t[2][2][i][j];
    }
    cout << ' ';
    for (int j = 1; j <= 3; j++) {
      cout << t[2][3][i][j];
    }
    cout << '\n';
  }
  cout << '\n';
  for (int i = 1; i <= 3; i++) {
    for (int j = 1; j <= 3; j++) {
      cout << t[3][1][i][j];
    }
    cout << ' ';
    for (int j = 1; j <= 3; j++) {
      cout << t[3][2][i][j];
    }
    cout << ' ';
    for (int j = 1; j <= 3; j++) {
      cout << t[3][3][i][j];
    }
    cout << '\n';
  }
  cout << '\n';
  return 0;
}
