#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:102400000,102400000")
using namespace std;
const int maxn = 100 + 10;
string s, t;
string maps[maxn];
map<pair<int, int>, int> mp;
void init() {
  mp.clear();
  for (int i = 1; i <= 3; i++) {
    for (int j = 1; j <= 9; j++) {
      if (j == 1 || j == 2 || j == 3)
        mp[pair<int, int>(i, j)] = 1;
      else if (j == 4 || j == 5 || j == 6)
        mp[pair<int, int>(i, j)] = 2;
      else
        mp[pair<int, int>(i, j)] = 3;
    }
  }
  for (int i = 4; i <= 6; i++) {
    for (int j = 1; j <= 9; j++) {
      if (j == 1 || j == 2 || j == 3)
        mp[pair<int, int>(i, j)] = 4;
      else if (j == 4 || j == 5 || j == 6)
        mp[pair<int, int>(i, j)] = 5;
      else
        mp[pair<int, int>(i, j)] = 6;
    }
  }
  for (int i = 7; i <= 9; i++) {
    for (int j = 1; j <= 9; j++) {
      if (j == 1 || j == 2 || j == 3)
        mp[pair<int, int>(i, j)] = 7;
      else if (j == 4 || j == 5 || j == 6)
        mp[pair<int, int>(i, j)] = 8;
      else
        mp[pair<int, int>(i, j)] = 9;
    }
  }
}
int judge(int x, int y) {
  while (x > 3) x -= 3;
  while (y > 3) y -= 3;
  return (x - 1) * 3 + y;
}
int main(int argc, char const *argv[]) {
  int num = 1;
  init();
  for (int i = 0; i < 11; i++) {
    getline(cin, s);
    t = "";
    t.push_back(' ');
    for (int j = 0; j < s.size(); j++) {
      if (s[j] == ' ') continue;
      t.push_back(s[j]);
    }
    if (i == 7 || i == 3) continue;
    maps[num++] = t;
  }
  int x, y;
  cin >> x >> y;
  num = judge(x, y);
  bool flag = false;
  for (int i = 1; i <= 9; i++) {
    for (int j = 1; j <= 9; j++) {
      if (mp[pair<int, int>(i, j)] == num && maps[i][j] == '.') {
        flag = true;
        maps[i][j] = '!';
      }
    }
  }
  if (!flag) {
    for (int i = 1; i <= 9; i++) {
      for (int j = 1; j <= 9; j++) {
        if (maps[i][j] == '.') maps[i][j] = '!';
      }
    }
  }
  for (int i = 1; i <= 9; i++) {
    if (i == 4 || i == 7) printf("\n");
    for (int j = 1; j <= 9; j++) {
      if (j == 4 || j == 7)
        printf(" %c", maps[i][j]);
      else
        printf("%c", maps[i][j]);
    }
    printf("\n");
  }
  return 0;
}
