#include <iostream>

using namespace std;

int data[8+1+1][8+1+1];

void func(int x,int y){
	data[y][x] = 0;
	for(int i=-3;i<=3;i++){
		if(x+i<0 || x+i > 9)continue;
		if(data[y][x+i] == 1)func(x+i,y);
	}
	for(int j=-3;j<=3;j++){
		if(y+j<0 || y+j>9)continue;
		if(data[y+j][x] == 1)func(x,y+j);
	}
}

void PrintBoard(){
	for(int i=1;i<=8;i++){
		for(int j=1;j<=8;j++){
			cout<<data[i][j];
		}
		cout<<endl;
	}
}

int main(){
	int n;
	cin>>n;
	for(int i=0;i<10;i++){
		for(int j=0;j<10;j++){
			data[i][j] = 0;
		}
	}
	char tmp;
	int x,y;
	for(int k=1;k<=n;k++){
		for(int i=1;i<=8;i++){
			for(int j=1;j<=8;j++){
				cin>>tmp;
				data[i][j] = tmp-'0';
			}
		}
		cin>>x;
		cin>>y;
		func(x,y);
		cout<<"Data "<<k<<":"<<endl;
		PrintBoard();
	}
	return 0;
}

/*
Sample Input
2

00010010
00000100
10001001
00100010
01000000
00001000
10100010
01010010
2
5

00010010
00000100
10001001
00100010
01000000
00001000
10100010
01010010
2
5
Output for the Sample Input
Data 1:
00000000
00000100
10001001
00100000
00000000
00001000
10100000
00000000
Data 2:
00000000
00000100
10001001
00100000
00000000
00001000
10100000
00000000
*/