#include <bits/stdc++.h>
using namespace std;
string a[10], b[10], c[10];
long long x, y;
bool f;
int main() {
  ios_base::sync_with_stdio(0);
  for (int i = 0; i < 9; i++) {
    cin >> a[i] >> b[i] >> c[i];
  }
  cin >> x >> y;
  x--;
  y--;
  x %= 3;
  y %= 3;
  if (x == 0 && y == 0) {
    for (int i = 0; i < 3; i++)
      for (int j = 0; j < 3; j++)
        if (a[i][j] == '.') {
          f = 1;
          a[i][j] = '!';
        }
  } else if (x == 1 && y == 0) {
    for (int i = 3; i < 6; i++)
      for (int j = 0; j < 3; j++)
        if (a[i][j] == '.') {
          f = 1;
          a[i][j] = '!';
        }
  } else if (x == 2 && y == 0) {
    for (int i = 6; i < 9; i++)
      for (int j = 0; j < 3; j++)
        if (a[i][j] == '.') {
          f = 1;
          a[i][j] = '!';
        }
  } else if (x == 0 && y == 1) {
    for (int i = 0; i < 3; i++)
      for (int j = 0; j < 3; j++)
        if (b[i][j] == '.') {
          f = 1;
          b[i][j] = '!';
        }
  } else if (x == 1 && y == 1) {
    for (int i = 3; i < 6; i++)
      for (int j = 0; j < 3; j++)
        if (b[i][j] == '.') {
          f = 1;
          b[i][j] = '!';
        }
  } else if (x == 2 && y == 1) {
    for (int i = 6; i < 9; i++)
      for (int j = 0; j < 3; j++)
        if (b[i][j] == '.') {
          f = 1;
          b[i][j] = '!';
        }
  } else if (x == 0 && y == 2) {
    for (int i = 0; i < 3; i++)
      for (int j = 0; j < 3; j++)
        if (c[i][j] == '.') {
          f = 1;
          c[i][j] = '!';
        }
  } else if (x == 1 && y == 2) {
    for (int i = 3; i < 6; i++)
      for (int j = 0; j < 3; j++)
        if (c[i][j] == '.') {
          f = 1;
          c[i][j] = '!';
        }
  } else if (x == 2 && y == 2) {
    for (int i = 6; i < 9; i++)
      for (int j = 0; j < 3; j++)
        if (c[i][j] == '.') {
          f = 1;
          c[i][j] = '!';
        }
  }
  for (int i = 0; i < 9; i++) {
    for (int j = 0; j < 3; j++)
      if (!f && a[i][j] == '.')
        cout << '!';
      else
        cout << a[i][j];
    cout << ' ';
    for (int j = 0; j < 3; j++)
      if (!f && b[i][j] == '.')
        cout << '!';
      else
        cout << b[i][j];
    cout << ' ';
    for (int j = 0; j < 3; j++)
      if (!f && c[i][j] == '.')
        cout << '!';
      else
        cout << c[i][j];
    cout << endl;
    if (i % 3 == 2) cout << endl;
  }
  return 0;
}
