#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <sstream>
#include <bitset>
 
#define INPUT_FROM_FILE (0) 
#if INPUT_FROM_FILE
#include <fstream>
#endif

void dfs(int w, int h, int x, int y, std::vector<std::string> &image){
	image[y][x] = '0';

	for(int i = 1; i <= 3; i++){
		if(x + i < w && image[y][x + i] == '1'){
			dfs(w, h, x + i, y, image);
		}
		if(x - i >= 0 && image[y][x - i] == '1'){
			dfs(w, h, x - i, y, image);
		}
		if(y + i < h && image[y + i][x] == '1'){
			dfs(w, h, x, y + i, image);
		}
		if(y - i >= 0 && image[y - i][x] == '1'){
			dfs(w, h, x, y - i, image);
		}
	}
	return;
}

int main(int argc, char **argv){
	int n;
	std::string buf;
	std::vector<std::string> image;
	int X, Y;
	int w = 8;
	int h = 8;

#if INPUT_FROM_FILE
	std::ifstream ifs("test.txt");
	//FILE *fp = fopen("test.txt", "r");
#endif

#if INPUT_FROM_FILE
	std::getline(ifs, buf);
#else
	std::getline(std::cin , buf);
#endif
	n = std::stoi(buf);

	for(int i = 0; i < n; i++){
		image.clear();
#if INPUT_FROM_FILE
		std::getline(ifs, buf);
#else
		std::getline(std::cin, buf);
#endif
		for(int y = 0; y < h; y++){
#if INPUT_FROM_FILE
			std::getline(ifs, buf);
#else
			std::getline(std::cin, buf);
#endif
			image.push_back(buf);
		}

#if INPUT_FROM_FILE
		std::getline(ifs, buf);
		X = std::stoi(buf);
		std::getline(ifs, buf);
		Y = std::stoi(buf);
#else
		std::getline(std::cin, buf);
		X = std::stoi(buf);
		std::getline(std::cin, buf);
		Y = std::stoi(buf);
#endif
		dfs(w, h, X - 1, Y - 1, image);

		std::cout << "Data " << i + 1 << ":" << std::endl;
		for(int y = 0; y < h; y++){
			std::cout << image[y] << std::endl;
		}
	}
 
#if INPUT_FROM_FILE
	//fclose(fp);
#endif
    return 0;
}
