#include<iostream>
using namespace std;

char bomb[8][8];
void dfs(int x, int y) {
	bomb[x][y] = '0';

	for (int i = -3;i <= 3;i++) {
		int ax = x + i;
		if (0 <= ax&&ax <= 7 && bomb[ax][y] == '1') { dfs(ax, y); }
	}
	for (int i = -3;i <= 3;i++) {
		int ay = y + i;
		if (0 <= ay&&ay <= 7 && bomb[x][ay] == '1') { dfs(x, ay); }
	}
}
int main() {
	int n;
	cin >> n;
	for (int a = 0;a < n;a++) {
		getchar();
		for (int i = 0;i < 8;i++) {
			for (int j = 0;j < 8;j++) {
				cin >> bomb[i][j];
			}
		}
		int x, y;
		cin >> x >> y;
		dfs(x - 1, y - 1);

		cout << "Data " << a + 1 << ":" << endl;

		for (int i = 0;i < 8;i++) {
			for (int j = 0;j < 8;j++) {
				cout << bomb[i][j];
				if (j == 7)cout << endl;
			}
		}

	}
	return 0;
}