#include <bits/stdc++.h>
const long long LINF = 1e18;
const int INF = 1e9;
const int M = 1e9 + 7;
const double EPS = 1e-9;
using namespace std;
char a[100][100];
bool check(int k, int l) {
  int r = k;
  bool fl = 0;
  int s = l;
  for (int i = r; i < r + 4; i++) {
    for (int j = s; j < s + 4; j++) {
      if (a[i][j] == '.') {
        fl = 1;
        a[i][j] = '!';
      }
    }
  }
  return fl;
}
int main(int argc, const char* argv[]) {
  int n = 11;
  string s;
  int koef;
  for (int i = 0; i < (int)(n); i++) {
    getline(cin, s);
    if (s == "") {
      for (int k = 0; k < (int)(12); k++) {
        a[i][k] = ' ';
      }
    }
    for (int k = 0; k < (int)(s.size()); k++) {
      a[i][k] = s[k];
    }
  }
  int x, y;
  cin >> x >> y;
  x--;
  y--;
  y = y % 3;
  x = x % 3;
  if (check(x * 4, y * 4))
    for (int i = 0; i < (int)(n); i++) {
      for (int j = 0; j < (int)(n); j++) {
        cout << a[i][j];
      }
      cout << '\n';
    }
  else {
    int k = 0;
    for (int i = 0; i < (int)(n); i++) {
      if (i == 3 || i == 7) {
        cout << '\n';
        continue;
      }
      for (int j = 0; j < (int)(n); j++) {
        if (a[i][j] == '.') a[i][j] = '!';
        cout << a[i][j];
      }
      cout << '\n';
    }
  }
  return 0;
}
