#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:102400000,102400000")
using namespace std;
const long long mod = 1e9 + 7;
const long long INF = 1e18 + 1LL;
const int inf = 1e9 + 1e8;
const double PI = acos(-1.0);
const int N = 1e5 + 100;
char s[100][100];
int x, y;
int main() {
  for (int i = 0; i <= 8; ++i) {
    for (int j = 0; j <= 8; ++j) {
      cin >> s[i][j];
    }
  }
  cin >> x >> y;
  x--, y--;
  x %= 3, y %= 3;
  int f = 1;
  for (int i = x * 3; i <= x * 3 + 2; ++i) {
    for (int j = y * 3; j <= y * 3 + 2; ++j) {
      if (s[i][j] == '.') {
        s[i][j] = '!';
        f = 0;
      }
    }
  }
  if (f) {
    for (int i = 0; i < 9; ++i) {
      int p = i % 3;
      if (p == 0 && i != 0) cout << ("\n");
      for (int j = 0; j < 9; ++j) {
        p = j % 3;
        if (p == 0 && j != 0) cout << " ";
        if (s[i][j] == 'o' || s[i][j] == 'x') {
          cout << s[i][j];
        } else
          cout << '!';
      }
      cout << ("\n");
    }
  } else {
    for (int i = 0; i < 9; ++i) {
      int p = i % 3;
      if (p == 0 && i != 0) cout << ("\n");
      for (int j = 0; j < 9; ++j) {
        p = j % 3;
        if (p == 0 && j != 0) cout << " ";
        cout << s[i][j];
      }
      cout << ("\n");
    }
  }
  return 0;
}
