#include<iostream>
#include<string>
using namespace std;
string m[15];
int solve(int x,int y){
  if(m[x][y]=='1'){
    m[x][y]='0';
    for(int i=-3;i<=3;i++){
      if(x+i>=0 && x+i<=7 && m[x+i][y]=='1') solve(x+i,y);
      if(y+i>=0 && y+i<=7 && m[x][y+i]=='1') solve(x,y+i);
    }
    return 1;
  }
  else return 1;
}
int main(void){
  int n,x,y;
  cin >> n;
  for(int k=1;k<=n;k++){
    for(int i=0;i<8;i++){
      cin >> m[i];
    }
    cin >> x >> y;
    solve(y-1,x-1);
    cout << "Data " << k << ":" << endl;
    for(int i=0;i<8;i++){
      cout << m[i] << endl;
    }
  }
}
