#include <bits/stdc++.h>
using namespace std;
int vis[10];
string mp[15];
void solve(int x, int y) {
  int i, j;
  if (x == 0) x = 3;
  if (y == 0) y = 3;
  x = 4 * (x - 1), y = 4 * (y - 1);
  for (i = x; i < x + 3; i++)
    for (j = y; j < y + 3; j++)
      if (mp[i][j] == '.') {
        for (int i = x; i < x + 3; i++)
          for (int j = y; j < y + 3; j++)
            if (mp[i][j] == '.') mp[i][j] = '!';
        return;
      }
  for (i = 0; i < 11; i++)
    for (j = 0; j < 11; j++) {
      if (mp[i][j] == '.') mp[i][j] = '!';
    }
  return;
}
int main() {
  int i, j, m, n;
  for (i = 0; i < 11; i++) getline(cin, mp[i]);
  cin >> m >> n;
  solve(m % 3, n % 3);
  for (i = 0; i < 11; i++) {
    cout << mp[i] << endl;
  }
  return 0;
}
