#include <bits/stdc++.h>
using namespace std;
long long int cons;
long long int check(long long int a) {
  if (a >= cons) a %= cons;
  return a;
}
long long int check2(long long int a) {
  a %= cons;
  if (a < 0) a += cons;
  return a;
}
long long int GCD(long long int a, long long int b) {
  if (b == 0) return a;
  return GCD(b, a % b);
}
long long int exp(long long int a, long long int n) {
  if (n == 0) return 1;
  if (n == 1) return check(a);
  long long int b = exp(a, n / 2);
  if (n % 2 == 0) return check(b * b);
  return check(b * check(b * a));
}
char arr[10][10][10][10];
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cons = 1e9 + 7;
  for (int i = 0; i < 3; i++) {
    for (int j = 0; j < 3; j++) {
      for (int k = 0; k < 3; k++) {
        cin >> arr[i][k][j];
      }
    }
  }
  int x1, y1;
  cin >> x1 >> y1;
  x1--;
  y1--;
  x1 %= 3;
  y1 %= 3;
  int coun = 0;
  for (int i = 0; i < 3; i++)
    for (int j = 0; j < 3; j++)
      if (arr[x1][y1][i][j] != 'x' && arr[x1][y1][i][j] != 'o') {
        arr[x1][y1][i][j] = '!';
        coun++;
      }
  if (!coun) {
    for (int i = 0; i < 3; i++)
      for (int j = 0; j < 3; j++)
        for (int k = 0; k < 3; k++)
          for (int l = 0; l < 3; l++)
            if (arr[i][j][k][l] != 'x' && arr[i][j][k][l] != 'o')
              arr[i][j][k][l] = '!';
  }
  for (int i = 0; i < 3; i++) {
    for (int j = 0; j < 3; j++) {
      for (int k = 0; k < 3; k++) {
        for (int l = 0; l < 3; l++) cout << arr[i][k][j][l];
        cout << " ";
      }
      cout << endl;
    }
    cout << endl;
  }
}
