#include<iostream>
#include<string>
using namespace std;
string g[8];

void solve(int y, int x) {
	g[y][x] = '0';
	for (int i = -3; i < 4; i++) {
		if (y + i >= 0 && y + i < 8 && g[y + i][x] == '1') {
			solve(y + i, x);
		}
	}
	for (int i = -3; i < 4; i++) {
		if (x + i >= 0 && x + i < 8 && g[y][x + i] == '1') {
			solve(y, x + i);
		}
	}
}

int main() {
	int n;
	cin >> n;
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < 8; j++) cin >> g[j];
		int x, y;
		cin >> x >> y;
		x--; y--;
		solve(y, x);
		cout << "Data " << i + 1 << ":" << endl;
		for (int j = 0; j < 8; j++) cout << g[j] << endl;
	}
}
