#include <bits/stdc++.h>
using namespace std;
int x, y;
int s[15];
char c[15][15];
int cal_zone(int x, int y) { return x / 3 * 3 + y / 3; }
void read() {
  memset(s, 0, sizeof(s));
  for (int i = 0; i < 9; i++) {
    for (int j = 0; j < 9; j++) {
      cin >> c[i][j];
      s[cal_zone(i, j)] += (c[i][j] != '.');
    }
  }
  cin >> x >> y;
  x--;
  y--;
}
void solve() {
  int z = x % 3 * 3 + y % 3;
  if (s[z] == 9) {
    for (int i = 0; i < 9; i++) {
      for (int j = 0; j < 9; j++) {
        if (c[i][j] == '.') c[i][j] = '!';
      }
    }
  } else {
    for (int i = 0; i < 3; i++) {
      for (int j = 0; j < 3; j++) {
        int nx = i + x % 3 * 3;
        int ny = j + y % 3 * 3;
        if (c[nx][ny] == '.') c[nx][ny] = '!';
      }
    }
  }
}
void print() {
  for (int i = 0; i < 9; i++) {
    if (i % 3 == 0 && i != 0) cout << endl;
    for (int j = 0; j < 9; j++) {
      if (j % 3 == 0 && j != 0) cout << " ";
      cout << c[i][j];
    }
    cout << endl;
  }
}
int main() {
  read();
  solve();
  print();
}
