//まともに使い方を理解していないくせにincludeしまくる人間のクズ
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <list>
#include <set>
#include <map>
#include <bitset>


//using namespace stdしないと表記がめんどくさいからね、仕方ないね
using namespace std;

//可読性を上げるためのdefineが仇となる典型的パターン
#define rep(i,n) for(int i = 0; i < n; i++)

//ローカル変数とグローバル変数は使い分けよう！
short n, x, y, j, k;
short planar[14][14];
int s;
unsigned long long int ans;

//関数って楽しいよね！（魔王スマイル）

void bom(short c, short d) {
	planar[c][d] = 0;
	if (planar[c + 1][d] != 0)
		bom(c + 1, d);
	if (planar[c - 1][d] != 0)
		bom(c - 1, d);
	if (planar[c][d + 1] != 0)
		bom(c, d + 1);
	if (planar[c][d - 1] != 0)
		bom(c, d - 1);
	if (planar[c + 2][d] != 0)
		bom(c + 2, d);
	if (planar[c - 2][d] != 0)
		bom(c - 2, d);
	if (planar[c][d + 2] != 0)
		bom(c, d + 2);
	if (planar[c][d - 2] != 0)
		bom(c, d - 2);
	if (planar[c - 3][d] != 0)
		bom(c - 3, d);
	if (planar[c + 3][d] != 0)
		bom(c + 3, d);
	if (planar[c][d + 3] != 0)
		bom(c, d + 3);
	if (planar[c][d - 3] != 0)
		bom(c, d - 3);
	return;
}
}

int main() {
	rep(i, 14) {
		planar[i][0] = 0;
		planar[i][1] = 0;
		planar[i][2] = 0;
		planar[i][11] = 0;
		planar[i][12] = 0;
		planar[i][13] = 0;
		planar[0][i] = 0;
		planar[1][i] = 0;
		planar[2][i] = 0;
		planar[11][i] = 0;
		planar[12][i] = 0;
		planar[13][i] = 0;
	}
	scanf("%d", &n);
	rep(i, n) {
		scanf("\n");
		for (j = 3; j <= 10; j++)
			for (k = 3; k <= 10; k++)
				scanf("%1d", &planar[j][k]);
		scanf("%d", &x);
		scanf("%d", &y);
		bom(y + 2, x + 2);
		printf("Data %d:\n", i + 1);
		for (j = 3; j <= 10; j++) {
			for (k = 3; k <= 10; k++) {
				printf("%d", planar[j][k]);
			}
			printf("\n");
		}
	}
	return 0;
}