#include <iostream>
#include <string>
#include <algorithm>

using namespace std;

void solve( int(*pmap)[9],int col,int row ) {
	pmap[row][col] = 0;

	for (int i = 1; i < 4; i++) {
		//left
		if (col - i > 0 && pmap[row][col - i] == 1) {
			solve(pmap, col-i, row);
		}
	    //right
		if (col + i < 9 && pmap[row][col + i] == 1) {
			solve(pmap, col+i, row);
		}
		//up
		if (row - i > 0 && pmap[row-i][col] == 1) {
			solve(pmap, col, row-i);
		}
	    //down
		if (row + i > 0 && pmap[row + i][col] == 1) {
			solve(pmap, col, row+i);
		}
	}
}

int main(void) {
	int n, round, i, j, x, y;
	int map[9][9];
	string str;

	cin >> n;
	for (round = 0; round < n; round++) {
		for (i = 1; i < 9; i++) {
			cin >> str;
			for (j = 0; j < 8; j++) {
				map[i][j + 1] = str[j] - '0';
			}
			str.clear();
		}
		cin >> x >> y;
        
		solve(map,x,y);

		cout << "Data " << round + 1 << ":" << endl;
		for (i = 1; i < 9; i++) {
			for (j = 1; j < 9; j++) {
				cout << map[i][j];
			}
			cout << endl;
		}

	}


	return 0;
}


