#include <cstdio>

using namespace std;

char mp[100][10][10];

int dx[14] = {1, 2, 3, -1, -2, -3, 0, 0, 0,  0,  0,  0};
int dy[14] = {0, 0, 0,  0,  0,  0, 1, 2, 3, -1, -2, -3};
int cc;

void def(int x, int y){
	mp[cc][y][x] = '0';
	
	for (int i = 0; i < 13; i++){
		int tx = x + dx[i];
		int ty = y + dy[i];
		
		if (mp[cc][ty][tx] == '1') def(tx, ty);
	}
}

int main(){
	
	int n;
	int x, y;
	
	scanf("%d", &n);
	scanf("");
	
	for (int num = 0; num < n; num++){
		for (int i = 1; i <= 8; i++){
			scanf("%s",  mp[cc][i]);
		}
		scanf("%d\n%d", &x, &y);
		def(x + 1, y);
		cc++;
	}
	
	cc = 0;
	for (int num = 0; num < n; num++){
		printf("Data %d:\n", cc + 1);
		for (int i = 1; i <= 8; i++){
			printf("%s\n",  mp[cc][i]);
		}
		cc++;
	}
}