#include <bits/stdc++.h>
using namespace std;
inline int read() {
  int k = 0, f = 1;
  char ch = getchar();
  while (ch < '0' || ch > '9') {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    k = k * 10 + ch - '0';
    ch = getchar();
  }
  return k * f;
}
inline void write(int x) {
  if (x < 0) putchar('-'), x = -x;
  if (x > 9) write(x / 10);
  putchar(x % 10 + '0');
}
inline void writeln(int x) {
  write(x);
  puts("");
}
string s[20];
inline void work() {
  for (int i = 1; i <= 11; i++)
    for (int j = 0; j < 11; j++)
      if (s[i][j] == '.') s[i][j] = '!';
}
int main() {
  for (int i = 1; i <= 11; i++) getline(cin, s[i]);
  int x = read(), y = read(), flag = 1;
  int le = 0, re = 0;
  if (x == 1 || x == 4 || x == 7) re = -1;
  if (x == 3 || x == 6 || x == 9) re = 1;
  if (y == 1 || y == 4 || y == 7) le = -1;
  if (y == 3 || y == 6 || y == 9) le = 1;
  if (le == -1 && re == -1) {
    for (int i = 1; i <= 3; i++)
      for (int j = 0; j < 3; j++)
        if (s[i][j] == '.') s[i][j] = '!', flag = 0;
    if (flag) work();
  } else if (le == 0 && re == -1) {
    for (int i = 1; i <= 3; i++)
      for (int j = 4; j < 7; j++)
        if (s[i][j] == '.') s[i][j] = '!', flag = 0;
    if (flag) work();
  } else if (le == 1 && re == -1) {
    for (int i = 1; i <= 3; i++)
      for (int j = 8; j < 11; j++)
        if (s[i][j] == '.') s[i][j] = '!', flag = 0;
    if (flag) work();
  }
  if (le == -1 && re == 0) {
    for (int i = 5; i <= 7; i++)
      for (int j = 0; j < 3; j++)
        if (s[i][j] == '.') s[i][j] = '!', flag = 0;
    if (flag) work();
  } else if (le == 0 && re == 0) {
    for (int i = 5; i <= 7; i++)
      for (int j = 4; j < 7; j++)
        if (s[i][j] == '.') s[i][j] = '!', flag = 0;
    if (flag) work();
  } else if (le == 1 && re == 0) {
    for (int i = 5; i <= 7; i++)
      for (int j = 8; j < 11; j++)
        if (s[i][j] == '.') s[i][j] = '!', flag = 0;
    if (flag) work();
  }
  if (le == -1 && re == 1) {
    for (int i = 9; i <= 11; i++)
      for (int j = 0; j < 3; j++)
        if (s[i][j] == '.') s[i][j] = '!', flag = 0;
    if (flag) work();
  } else if (le == 0 && re == 1) {
    for (int i = 9; i <= 11; i++)
      for (int j = 4; j < 7; j++)
        if (s[i][j] == '.') s[i][j] = '!', flag = 0;
    if (flag) work();
  } else if (le == 1 && re == 1) {
    for (int i = 9; i <= 11; i++)
      for (int j = 8; j < 11; j++)
        if (s[i][j] == '.') s[i][j] = '!', flag = 0;
    if (flag) work();
  }
  for (int i = 1; i <= 11; i++) cout << s[i] << endl;
}
