#include <bits/stdc++.h>
using namespace std;
int a[10][10];
int n, m;
int able;
int sn, sm, an, am;
char s[1000];
void print() {
  for (int i = 1; i <= 9; i++) {
    for (int j = 1; j <= 9; j++) {
      switch (a[i][j]) {
        case 0:
          putchar('.');
          break;
        case 1:
          putchar('x');
          break;
        case 2:
          putchar('o');
          break;
        case 4:
          putchar('!');
          break;
      }
      if (j % 3 == 0) putchar(32);
    }
    puts("");
    if (i % 3 == 0) puts("");
  }
}
int main() {
  int nowi = 0, nowj = 0;
  for (int i = 1; i <= 11; i++) {
    if (i == 4 || i == 7) continue;
    nowi++;
    nowj = 0;
    scanf("%s", s);
    for (int j = 0; j < 3; j++) {
      nowj++;
      if (s[j] == 'x') a[nowi][nowj] = 1;
      if (s[j] == 'o') a[nowi][nowj] = 2;
    }
    scanf("%s", s);
    for (int j = 0; j < 3; j++) {
      nowj++;
      if (s[j] == 'x') a[nowi][nowj] = 1;
      if (s[j] == 'o') a[nowi][nowj] = 2;
    }
    scanf("%s", s);
    for (int j = 0; j < 3; j++) {
      nowj++;
      if (s[j] == 'x') a[nowi][nowj] = 1;
      if (s[j] == 'o') a[nowi][nowj] = 2;
    }
  }
  scanf("%d%d", &n, &m);
  sn = n % 3, sm = m % 3;
  if (sn == 0) sn = 3;
  if (sm == 0) sm = 3;
  int able = 1;
  for (int i = (sn - 1) * 3 + 1; i <= sn * 3; i++)
    for (int j = (sm - 1) * 3 + 1; j <= sm * 3; j++)
      if (a[i][j] == 0) {
        able = 0;
        break;
      }
  if (able == 1) {
    for (int i = 1; i <= 9; i++)
      for (int j = 1; j <= 9; j++)
        if (a[i][j] == 0) a[i][j] = 4;
  } else {
    for (int i = (sn - 1) * 3 + 1; i <= sn * 3; i++)
      for (int j = (sm - 1) * 3 + 1; j <= sm * 3; j++)
        if (a[i][j] == 0) a[i][j] = 4;
  }
  print();
}
