#include <bits/stdc++.h>
using namespace std;
char s[100][100];
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  bool flag = true;
  long long i, x, y, k, j;
  char ch, r, m;
  string jkl;
  for (long long i = 1; i <= 11; i++) {
    if (i == 4 or i == 8) continue;
    for (long long j = 1; j <= 11; j++) {
      if (j == 4 or j == 8)
        s[i][j] = '*';
      else
        cin >> ch, s[i][j] = ch;
    }
  }
  cin >> x >> y;
  if (x == 1 or x == 4 or x == 7)
    r = 'U';
  else if (x == 2 or x == 5 or x == 8)
    r = 'M';
  else
    r = 'B';
  if (y == 1 or y == 4 or y == 7)
    m = 'L';
  else if (y == 2 or y == 5 or y == 8)
    m = 'M';
  else
    m = 'R';
  if (r == 'U') {
    if (m == 'L') {
      for (i = 1; i <= 3; i++)
        for (long long j = 1; j <= 3; j++)
          if (s[i][j] == '.') s[i][j] = '!', flag = false;
    } else if (m == 'M') {
      for (i = 1; i <= 3; i++)
        for (long long j = 5; j <= 7; j++)
          if (s[i][j] == '.') s[i][j] = '!', flag = false;
    } else {
      for (i = 1; i <= 3; i++)
        for (long long j = 9; j <= 11; j++)
          if (s[i][j] == '.') s[i][j] = '!', flag = false;
    }
  } else if (r == 'M') {
    if (m == 'L') {
      for (i = 5; i <= 7; i++)
        for (long long j = 1; j <= 3; j++)
          if (s[i][j] == '.') s[i][j] = '!', flag = false;
    } else if (m == 'M') {
      for (i = 5; i <= 7; i++)
        for (long long j = 5; j <= 7; j++)
          if (s[i][j] == '.') s[i][j] = '!', flag = false;
    } else {
      for (i = 5; i <= 7; i++)
        for (long long j = 9; j <= 11; j++)
          if (s[i][j] == '.') s[i][j] = '!', flag = false;
    }
  } else {
    if (m == 'L') {
      for (i = 9; i <= 11; i++)
        for (long long j = 1; j <= 3; j++)
          if (s[i][j] == '.') s[i][j] = '!', flag = false;
    } else if (m == 'M') {
      for (i = 9; i <= 11; i++)
        for (long long j = 5; j <= 7; j++)
          if (s[i][j] == '.') s[i][j] = '!', flag = false;
    } else {
      for (i = 9; i <= 11; i++)
        for (long long j = 9; j <= 11; j++)
          if (s[i][j] == '.') s[i][j] = '!', flag = false;
    }
  }
  if (flag == true) {
    for (i = 1; i <= 11; i++) {
      if (i == 4 or i == 8) {
        cout << "           " << endl;
        continue;
      }
      for (j = 1; j <= 11; j++) {
        if (j == 4 or j == 8) {
          cout << " ";
          continue;
        }
        if (s[i][j] == '.')
          cout << "!";
        else
          cout << s[i][j];
      }
      cout << endl;
    }
  } else {
    for (i = 1; i <= 11; i++) {
      if (i == 4 or i == 8) {
        cout << "           " << endl;
        continue;
      }
      for (j = 1; j <= 11; j++) {
        if (s[i][j] == '*')
          cout << " ";
        else
          cout << s[i][j];
      }
      cout << endl;
    }
  }
}
