#include <iostream>
#include <cstdio>
using namespace std;

#define SIZE 8

//????????????????????????
bool isWithin(int x, int y){
	return 0 <= x && x < SIZE && 0 <= y && y < SIZE;
}

//x,y:??????????????§?¨?
void explode(int field[SIZE][SIZE], int x, int y){
	field[y][x] = 0;
	int dx[4] = {1, 0, -1, 0};
	int dy[4] = {0, 1, 0, -1};
	for(int i=1;i<=3;i++){//??????????????????3???????¢¨????±????
		for(int j=0;j<4;j++){
			int dstX = x + i * dx[j];
			int dstY = y + i * dy[j];
			if(isWithin(dstX, dstY)){
				if(field[dstY][dstX] == 1){
					explode(field, dstX, dstY);
				}
			}
		}
	}
}


void solve(){
	int field[SIZE][SIZE];
	for(int y=0;y<SIZE;y++){
		char line[9];
		scanf("%s", &line);
		for(int x=0;x<SIZE;x++){
			//'0'?????´???0, '1'?????´???1?????£??\?????????
			field[y][x] = line[x] - '0';
		}
		scanf("\n");
	}
	int fx, fy;//???????????????????????§?¨?(??\??????-1)
	scanf("%d\n%d\n\n", &fx, &fy);
	fx--;
	fy--;
	explode(field,fx,fy);
	
	for(int y=0;y<SIZE;y++){
		for(int x=0;x<SIZE;x++){
			printf("%d", field[y][x]);
		}
		printf("\n");
	}
}

int main() {
	int n;
	scanf("%d\n\n", &n);
	for(int i=0;i<n;i++){
		printf("Data %d:\n", i+1);
		solve();
	}
	
	return 0;
}