#include <iostream>
using namespace std;

#define SZ 8

int fld[SZ][SZ];

void func(int x, int y){
  fld[x][y] = 0;
//  cout << "bomb: (" << x << "," << y << ")" << endl;
  for (int xx=x-3; xx<=x+3; xx++){
    if (xx<0 || xx>=SZ) continue;
    if (fld[xx][y]) func(xx, y);
  }
  for (int yy=y-3; yy<=y+3; yy++){
    if (yy<0 || yy>=SZ) continue;
    if (fld[x][yy]) func(x, yy);
  }
}

int main(void){
  int numOfData;
  int x,y;
  char c;
  
  cin >> numOfData;
  for (int i=0; i<numOfData; i++){
    for (int j=0; j<SZ; j++){
      for (int k=0; k<SZ; k++){
        cin >> c;
        fld[k][j] = c-'0';
      }
    }
    cin >> x >> y;
    x--; y--;
    func(x, y);
    cout << "Data " << (i+1) << ":" << endl;
    for (int j=0; j<SZ; j++){
      for (int k=0; k<SZ; k++){
        cout << !!fld[k][j];
      }
      cout << endl;
    }
  }
  return 0;
}
