#include <bits/stdc++.h>
using namespace std;
long long int mod_expo(long long int MOD, long long int a, long long int b) {
  long long int ans = 1;
  while (b) {
    if (b % 2) {
      ans *= a;
      ans %= MOD;
    }
    b /= 2;
    a *= a;
    a %= MOD;
  }
  return ans % MOD;
}
void display(vector<int> v1) {
  for (int i = 0; i < v1.size(); i++) {
    cout << v1[i] << " ";
  }
  cout << endl;
}
int dx[8] = {0, 1, 0, -1, 1, 1, -1, -1};
int dy[8] = {1, 0, -1, 0, 1, -1, 1, -1};
using namespace std;
char arr[120][120];
int cntr = 0;
void paintit(int largerow, int largecol) {
  if (largerow == 1 and largecol == 1) {
    for (int i = 1; i <= 3; i += 1) {
      for (int j = 1; j <= 3; j += 1) {
        if (arr[i][j] == '.') {
          cntr += 1;
          arr[i][j] = '!';
        }
      }
    }
  } else if (largerow == 1 and largecol == 2) {
    for (int i = 1; i <= 3; i += 1) {
      for (int j = 4; j <= 6; j += 1) {
        if (arr[i][j] == '.') {
          cntr += 1;
          arr[i][j] = '!';
        }
      }
    }
  } else if (largerow == 1 and largecol == 3) {
    for (int i = 1; i <= 3; i += 1) {
      for (int j = 7; j <= 9; j += 1) {
        if (arr[i][j] == '.') {
          cntr += 1;
          arr[i][j] = '!';
        }
      }
    }
  } else if (largerow == 2 and largecol == 1) {
    for (int i = 4; i <= 6; i += 1) {
      for (int j = 1; j <= 3; j += 1) {
        if (arr[i][j] == '.') {
          cntr += 1;
          arr[i][j] = '!';
        }
      }
    }
  } else if (largerow == 2 and largecol == 2) {
    for (int i = 4; i <= 6; i += 1) {
      for (int j = 4; j <= 6; j += 1) {
        if (arr[i][j] == '.') {
          cntr += 1;
          arr[i][j] = '!';
        }
      }
    }
  } else if (largerow == 2 and largecol == 3) {
    for (int i = 4; i <= 6; i += 1) {
      for (int j = 7; j <= 9; j += 1) {
        if (arr[i][j] == '.') {
          cntr += 1;
          arr[i][j] = '!';
        }
      }
    }
  } else if (largerow == 3 and largecol == 1) {
    for (int i = 7; i <= 9; i += 1) {
      for (int j = 1; j <= 3; j += 1) {
        if (arr[i][j] == '.') {
          cntr += 1;
          arr[i][j] = '!';
        }
      }
    }
  } else if (largerow == 3 and largecol == 2) {
    for (int i = 7; i <= 9; i += 1) {
      for (int j = 4; j <= 6; j += 1) {
        if (arr[i][j] == '.') {
          cntr += 1;
          arr[i][j] = '!';
        }
      }
    }
  } else if (largerow == 3 and largecol == 3) {
    for (int i = 7; i <= 9; i += 1) {
      for (int j = 7; j <= 9; j += 1) {
        if (arr[i][j] == '.') {
          cntr += 1;
          arr[i][j] = '!';
        }
      }
    }
  }
}
void printit() {
  for (int i = 1; i <= 9; i += 1) {
    for (int j = 1; j <= 9; j += 1) {
      cout << arr[i][j];
      if (j % 3 == 0) {
        cout << " ";
      }
    }
    if (i % 3 == 0) {
      cout << endl;
    }
    cout << endl;
  }
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  for (int i = 1; i <= 9; i += 1) {
    for (int j = 1; j <= 9; j += 1) {
      cin >> arr[i][j];
    }
  }
  int wherelastrow;
  int wherelastcol;
  cin >> wherelastrow >> wherelastcol;
  int whichrowofbig;
  int whichcolofbig;
  if (wherelastrow == 1 or wherelastrow == 4 or wherelastrow == 7) {
    whichrowofbig = 1;
  } else if (wherelastrow == 2 or wherelastrow == 5 or wherelastrow == 8) {
    whichrowofbig = 2;
  } else {
    whichrowofbig = 3;
  }
  if (wherelastcol == 1 or wherelastcol == 4 or wherelastcol == 7) {
    whichcolofbig = 1;
  } else if (wherelastcol == 2 or wherelastcol == 5 or wherelastcol == 8) {
    whichcolofbig = 2;
  } else {
    whichcolofbig = 3;
  }
  paintit(whichrowofbig, whichcolofbig);
  if (cntr == 0) {
    for (int i = 1; i <= 9; i += 1) {
      for (int j = 1; j <= 9; j += 1) {
        if (arr[i][j] == '.') {
          arr[i][j] = '!';
        }
      }
    }
  }
  printit();
  return 0;
}
