#include <bits/stdc++.h>
int a[100][100];
int b[100][100];
using namespace std;
int main() {
  for (int i = 1; i <= 9; i++) {
    string s, k, l;
    cin >> s >> k >> l;
    for (int j = 0; j < 3; j++) {
      if (s[j] == 'x') a[i][j + 1] = 1;
      if (s[j] == 'o') a[i][j + 1] = 3;
      if (k[j] == 'x') a[i][j + 4] = 1;
      if (k[j] == 'o') a[i][j + 4] = 3;
      if (l[j] == 'x') a[i][j + 7] = 1;
      if (l[j] == 'o') a[i][j + 7] = 3;
    }
  }
  int x, y;
  cin >> x >> y;
  if (x % 3 == 0)
    x = 3;
  else
    x = x % 3;
  if (y % 3 == 0)
    y = 3;
  else
    y = y % 3;
  int free = 0;
  for (int i = x * 3 - 2; i <= x * 3; i++) {
    for (int j = y * 3 - 2; j <= y * 3; j++) {
      if (a[i][j] == 0) {
        a[i][j] = 2;
        free++;
      }
    }
  }
  if (free) {
    for (int i = 1; i <= 9; i++) {
      for (int j = 1; j <= 9; j++) {
        if (j % 3 == 1) cout << " ";
        if (a[i][j] == 0) cout << '.';
        if (a[i][j] == 1) cout << 'x';
        if (a[i][j] == 2) cout << '!';
        if (a[i][j] == 3) cout << 'o';
      }
      cout << endl;
      if (i % 3 == 0) cout << endl;
    }
  } else {
    for (int i = 1; i <= 9; i++) {
      for (int j = 1; j <= 9; j++) {
        if (j % 3 == 1) cout << " ";
        if (a[i][j] == 0) cout << '!';
        if (a[i][j] == 1) cout << 'x';
        if (a[i][j] == 2) cout << '!';
        if (a[i][j] == 3) cout << 'o';
      }
      cout << endl;
      if (i % 3 == 0) cout << endl;
    }
  }
  return 0;
}
