#include <bits/stdc++.h>
using namespace std;
char table[10][10];
void print();
int main() {
  for (int i = 1; i < 10; i++) {
    string a, b, c;
    cin >> a >> b >> c;
    table[i][1] = a[0];
    table[i][2] = a[1];
    table[i][3] = a[2];
    table[i][4] = b[0];
    table[i][5] = b[1];
    table[i][6] = b[2];
    table[i][7] = c[0];
    table[i][8] = c[1];
    table[i][9] = c[2];
  }
  int r, c;
  cin >> r >> c;
  int a;
  if (r % 3 == 1)
    a = 0;
  else if (r % 3 == 2)
    a = 1;
  else
    a = 2;
  int b;
  if (c % 3 == 1)
    b = 0;
  else if (c % 3 == 2)
    b = 1;
  else
    b = 2;
  bool flag = false;
  for (int i = a * 3 + 1; i <= a * 3 + 3; i++) {
    for (int j = b * 3 + 1; j <= b * 3 + 3; j++) {
      if (table[i][j] == '.') {
        table[i][j] = '!';
        flag = true;
      }
    }
  }
  if (!flag) {
    for (int i = 1; i < 10; i++)
      for (int j = 1; j < 10; j++)
        if (table[i][j] == '.') table[i][j] = '!';
  }
  print();
  cout << endl;
  return 0;
}
void print() {
  for (int i = 1; i < 10; i++) {
    if (i % 3 == 1 && i > 1) cout << endl;
    cout << table[i][1] << table[i][2] << table[i][3] << ' ';
    cout << table[i][4] << table[i][5] << table[i][6] << ' ';
    cout << table[i][7] << table[i][8] << table[i][9] << endl;
  }
}
