#include <bits/stdc++.h>
using namespace std;
const long long N = 2e5 + 5;
char a[100][100];
int32_t main() {
  long long x, y;
  for (long long i = 1; i <= 9; i++) {
    for (long long j = 1; j <= 9; j++) {
      cin >> a[i][j];
    }
  }
  cin >> x >> y;
  map<pair<long long, long long>, long long> m;
  for (long long i = 1; i <= 9; i++) {
    if (i % 3 == 1) {
      m[make_pair(i, 1)] = 1;
      m[make_pair(i, 4)] = 1;
      m[make_pair(i, 7)] = 1;
      m[make_pair(i, 2)] = 2;
      m[make_pair(i, 5)] = 2;
      m[make_pair(i, 8)] = 2;
      m[make_pair(i, 3)] = 3;
      m[make_pair(i, 6)] = 3;
      m[make_pair(i, 9)] = 3;
    } else if (i % 3 == 2) {
      m[make_pair(i, 1)] = 1;
      m[make_pair(i, 4)] = 1;
      m[make_pair(i, 7)] = 1;
      m[make_pair(i, 2)] = 2;
      m[make_pair(i, 5)] = 2;
      m[make_pair(i, 8)] = 2;
      m[make_pair(i, 3)] = 3;
      m[make_pair(i, 6)] = 3;
      m[make_pair(i, 9)] = 3;
      for (long long j = 1; j <= 9; j++) {
        m[make_pair(i, j)] += 3;
      }
    } else {
      m[make_pair(i, 1)] = 1;
      m[make_pair(i, 4)] = 1;
      m[make_pair(i, 7)] = 1;
      m[make_pair(i, 2)] = 2;
      m[make_pair(i, 5)] = 2;
      m[make_pair(i, 8)] = 2;
      m[make_pair(i, 3)] = 3;
      m[make_pair(i, 6)] = 3;
      m[make_pair(i, 9)] = 3;
      for (long long j = 1; j <= 9; j++) {
        m[make_pair(i, j)] += 6;
      }
    }
  }
  long long curmat = m[make_pair(x, y)];
  if (curmat <= 3) {
    long long ans = 0;
    for (long long i = 1; i <= 3; i++) {
      for (long long j = 1 + (curmat - 1) * 3; j <= 3 + (curmat - 1) * 3; j++) {
        if (a[i][j] == '.') {
          a[i][j] = '!';
          ans++;
        }
      }
    }
    if (ans == 0) {
      for (long long i = 1; i <= 9; i++) {
        for (long long j = 1; j <= 9; j++) {
          if (a[i][j] == '.') a[i][j] = '!';
        }
      }
    }
    for (long long i = 1; i <= 9; i++) {
      for (long long j = 1; j <= 9; j++) {
        cout << a[i][j];
        if (j % 3 == 0) cout << " ";
      }
      cout << "\n";
      if (i % 3 == 0) cout << "\n";
    }
  } else if (curmat <= 6) {
    long long ans = 0;
    for (long long i = 4; i <= 6; i++) {
      for (long long j = 1 + (curmat - 4) * 3; j <= 3 + (curmat - 4) * 3; j++) {
        if (a[i][j] == '.') {
          a[i][j] = '!';
          ans++;
        }
      }
    }
    if (ans == 0) {
      for (long long i = 1; i <= 9; i++) {
        for (long long j = 1; j <= 9; j++) {
          if (a[i][j] == '.') a[i][j] = '!';
        }
      }
    }
    for (long long i = 1; i <= 9; i++) {
      for (long long j = 1; j <= 9; j++) {
        cout << a[i][j];
        if (j % 3 == 0) cout << " ";
      }
      cout << "\n";
      if (i % 3 == 0) cout << "\n";
    }
  } else {
    long long ans = 0;
    for (long long i = 7; i <= 9; i++) {
      for (long long j = 1 + (curmat - 7) * 3; j <= 3 + (curmat - 7) * 3; j++) {
        if (a[i][j] == '.') {
          a[i][j] = '!';
          ans++;
        }
      }
    }
    if (ans == 0) {
      for (long long i = 1; i <= 9; i++) {
        for (long long j = 1; j <= 9; j++) {
          if (a[i][j] == '.') a[i][j] = '!';
        }
      }
    }
    for (long long i = 1; i <= 9; i++) {
      for (long long j = 1; j <= 9; j++) {
        cout << a[i][j];
        if (j % 3 == 0) cout << " ";
      }
      cout << "\n";
      if (i % 3 == 0) cout << "\n";
    }
  }
}
