#include <bits/stdc++.h>
using namespace std;
string s[81], a[5], b[5], c[5], d[5], e[5], f[5], g[5], h[5], k[5];
int x, y;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  for (int i = 1; i <= 3; i++) cin >> a[i] >> b[i] >> c[i];
  for (int i = 1; i <= 3; i++) cin >> d[i] >> e[i] >> f[i];
  for (int i = 1; i <= 3; i++) cin >> g[i] >> h[i] >> k[i];
  cin >> x >> y;
  while (x > 3) x -= 3;
  while (y > 3) y -= 3;
  bool good = false;
  if (x == 1 && y == 1) {
    for (int i = 1; i <= 3; i++)
      for (int j = 0; j < 3; j++) {
        if (a[i][j] != 'x' && a[i][j] != 'o') {
          a[i][j] = '!';
          good = true;
        }
      }
  }
  if (x == 1 && y == 2) {
    for (int i = 1; i <= 3; i++)
      for (int j = 0; j < 3; j++) {
        if (b[i][j] != 'x' && b[i][j] != 'o') {
          b[i][j] = '!';
          good = true;
        }
      }
  }
  if (x == 1 && y == 3) {
    for (int i = 1; i <= 3; i++)
      for (int j = 0; j < 3; j++) {
        if (c[i][j] != 'x' && c[i][j] != 'o') {
          c[i][j] = '!';
          good = true;
        }
      }
  }
  if (x == 2 && y == 1) {
    for (int i = 1; i <= 3; i++)
      for (int j = 0; j < 3; j++) {
        if (d[i][j] != 'x' && d[i][j] != 'o') {
          d[i][j] = '!';
          good = true;
        }
      }
  }
  if (x == 2 && y == 2) {
    for (int i = 1; i <= 3; i++)
      for (int j = 0; j < 3; j++) {
        if (e[i][j] != 'x' && e[i][j] != 'o') {
          e[i][j] = '!';
          good = true;
        }
      }
  }
  if (x == 2 && y == 3) {
    for (int i = 1; i <= 3; i++)
      for (int j = 0; j < 3; j++) {
        if (f[i][j] != 'x' && f[i][j] != 'o') {
          f[i][j] = '!';
          good = true;
        }
      }
  }
  if (x == 3 && y == 1) {
    for (int i = 1; i <= 3; i++)
      for (int j = 0; j < 3; j++) {
        if (g[i][j] != 'x' && g[i][j] != 'o') {
          g[i][j] = '!';
          good = true;
        }
      }
  }
  if (x == 3 && y == 2) {
    for (int i = 1; i <= 3; i++)
      for (int j = 0; j < 3; j++) {
        if (h[i][j] != 'x' && h[i][j] != 'o') {
          h[i][j] = '!';
          good = true;
        }
      }
  }
  if (x == 3 && y == 3) {
    for (int i = 1; i <= 3; i++)
      for (int j = 0; j < 3; j++) {
        if (k[i][j] != 'x' && k[i][j] != 'o') {
          k[i][j] = '!';
          good = true;
        }
      }
  }
  if (!good) {
    for (int i = 1; i <= 3; i++)
      for (int j = 0; j < 3; j++) {
        if (a[i][j] == '.') a[i][j] = '!';
        if (b[i][j] == '.') b[i][j] = '!';
        if (c[i][j] == '.') c[i][j] = '!';
        if (d[i][j] == '.') d[i][j] = '!';
        if (e[i][j] == '.') e[i][j] = '!';
        if (f[i][j] == '.') f[i][j] = '!';
        if (g[i][j] == '.') g[i][j] = '!';
        if (h[i][j] == '.') h[i][j] = '!';
        if (k[i][j] == '.') k[i][j] = '!';
      }
  }
  for (int i = 1; i <= 3; i++) {
    cout << a[i] << ' ' << b[i] << ' ' << c[i] << endl;
  }
  cout << endl;
  for (int i = 1; i <= 3; i++) {
    cout << d[i] << ' ' << e[i] << ' ' << f[i] << endl;
  }
  cout << endl;
  for (int i = 1; i <= 3; i++) {
    cout << g[i] << ' ' << h[i] << ' ' << k[i] << endl;
  }
  return 0;
}
