#include <bits/stdc++.h>
using namespace std;
int INF = 1e9 + 5;
int main() {
  vector<vector<char>> grid(9, vector<char>(9));
  for (int i = 0; i < 9; i++) {
    for (int j = 0; j < 9; j++) {
      scanf(" %c", &grid[i][j]);
    }
  }
  int r, c;
  cin >> r >> c;
  int square_r = (r - 1) % 3, square_c = (c - 1) % 3;
  int r_start = 3 * square_r, c_start = 3 * square_c;
  bool filled = 1;
  for (int i = r_start; i < r_start + 3; i++) {
    for (int j = c_start; j < c_start + 3; j++) {
      if (grid[i][j] == '.') {
        filled = 0;
        grid[i][j] = '!';
      }
    }
  }
  for (int i = 0; i < 9; i++) {
    for (int j = 0; j < 9; j++) {
      if (filled && grid[i][j] == '.') {
        cout << '!';
      } else {
        cout << grid[i][j];
      }
      if (j % 3 == 2) {
        cout << ' ';
      }
    }
    cout << '\n';
    if (i % 3 == 2) {
      cout << '\n';
    }
  }
}
