#include<iostream>
#include<string>
#include<vector>
using namespace std;

void bom(int x,int y,vector<string>& in){
  //cout<<1<<endl;
  if(in[x-1][y-1]=='1'){in[x-1][y-1]='0';bom(x,y,in);}
  if(x-2>=0)if(in[x-2][y-1]=='1'){in[x-2][y-1]=='0';bom(x-1,y,in);}
  if(x-3>=0)if(in[x-3][y-1]=='1'){in[x-3][y-1]=='0';bom(x-2,y,in);}
  if(x-4>=0)if(in[x-4][y-1]=='1'){in[x-4][y-1]=='0';bom(x-3,y,in);}
  if(x<8)if(in[x][y-1]=='1'){in[x][y-1]=='0';bom(x+1,y,in);}
  if(x+1<8)if(in[x+1][y-1]=='1'){in[x+1][y-1]=='0';bom(x+2,y,in);}
  if(x+2<8)if(in[x+2][y-1]=='1'){in[x+2][y-1]=='0';bom(x+3,y,in);}
  if(y-2>=0)if(in[x-1][y-2]=='1'){in[x-1][y-2]=='0';bom(x,y-1,in);}
  if(y-3>=0)if(in[x-1][y-3]=='1'){in[x-1][y-3]=='0';bom(x,y-2,in);}
  if(y-4>=0)if(in[x-1][y-4]=='1'){in[x-1][y-4]=='0';bom(x,y-3,in);}
  if(y<8)if(in[x-1][y]=='1'){in[x-1][y]=='0';bom(x,y+1,in);}
  if(y+1<8)if(in[x-1][y+1]=='1'){in[x-1][y+1]=='0';bom(x,y+2,in);}
  if(y+2<8)if(in[x-1][y+2]=='1'){in[x-1][y+2]=='0';bom(x,y+3,in);}
  //cout<<2<<endl;
  return;
}

int main(){

  int n;
  cin>>n;
  for(int i=1;i<=n;i++){
    vector<string>in;
    string tmp;
    for(int j=0;j<8;j++){
      cin>>tmp;
      in.push_back(tmp);
    }
    int x,y;
    cin>>x>>y;
    //cout<<in[y-1][x-1]<<endl;
    bom(y,x,in);

    cout<<"Date "<<i<<":"<<endl;
    for(int i=0;i<8;i++)
      cout<<in[i]<<endl;


  }
}