#include <bits/stdc++.h>
using namespace std;
char mat[3][3][3][3];
string x[9][3];
int ni, nj;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  for (int fi = 0; fi < 9; fi++)
    for (int fj = 0; fj < 3; fj++) cin >> x[fi][fj];
  for (int fi = 0; fi < 3; fi++)
    for (int fj = 0; fj < 3; fj++)
      for (int ci = 0; ci < 3; ci++)
        for (int cj = 0; cj < 3; cj++)
          mat[fi][fj][ci][cj] = x[fi * 3 + ci][fj][cj];
  cin >> ni >> nj, ni = (ni - 1) % 3, nj = (nj - 1) % 3;
  bool no_free = true;
  for (int ci = 0; ci < 3; ci++)
    for (int cj = 0; cj < 3; cj++)
      if (mat[ni][nj][ci][cj] == '.') {
        no_free = false;
        mat[ni][nj][ci][cj] = '!';
      }
  if (no_free) {
    for (int fi = 0; fi < 3; fi++)
      for (int fj = 0; fj < 3; fj++)
        for (int ci = 0; ci < 3; ci++)
          for (int cj = 0; cj < 3; cj++)
            if (mat[fi][fj][ci][cj] == '.') mat[fi][fj][ci][cj] = '!';
  }
  for (int fi = 0; fi < 3; fi++)
    for (int fj = 0; fj < 3; fj++)
      for (int ci = 0; ci < 3; ci++)
        for (int cj = 0; cj < 3; cj++)
          x[fi * 3 + ci][fj][cj] = mat[fi][fj][ci][cj];
  for (int fi = 0; fi < 9; fi++) {
    for (int fj = 0; fj < 3; fj++) cout << x[fi][fj] << " ";
    cout << endl;
    if (fi % 3 == 2) cout << endl;
  }
  return 0;
}
