#include <iostream>
#include <vector>
#include <string>
#include <stack>
#include <map>
#include <algorithm>
#include <iomanip>
#include <cmath>
using namespace std;

#define MAXV 1000000000
#define MOD 1000000007
using ll = long long;

bool operator<(const pair<int, int>& a, const pair<int, int>& b) {
	if (a.first == b.first) {
		return a.second < b.second;
	}
	return a.first < b.first;
}



void rec(int x, int y, vector<string>& v) {
	v[y][x] = '0';

	for (int i = 1; i <= 3; ++i) {
		int nx = x - i;
		if (nx >= 0 && v[y][nx]=='1') {
			rec(nx, y, v);
		}
	}

	for (int i = 1; i <= 3; ++i) {
		int nx = x + i;
		if (nx <8 && v[y][nx] == '1') {
			rec(nx, y, v);
		}
	}

	for (int i = 1; i <= 3; ++i) {
		int ny = y - i;
		if (ny >=0 && v[ny][x] == '1') {
			rec(x, ny, v);
		}
	}

	for (int i = 1; i <= 3; ++i) {
		int ny = y + i;
		if (ny <8 && v[ny][x] == '1') {
			rec(x, ny, v);
		}
	}
}
int main() {

	int N;
	cin >> N;
	//cin.ignore();
	for (int i = 0; i < N; ++i) {
        cout << "Data " << i+1 << ":" << endl;
		vector<string> v;
		for (int j = 0; j < 8; ++j) {
			string s;
            cin >> s;
			v.push_back(s);
		}

		int X, Y; cin >> X >> Y;

		X--;
		Y--;
        //cout << X << " " << Y << endl;
		rec(X, Y, v);

		for (int j = 0; j < 8; ++j) {
			for (int k = 0; k < 8; ++k) {
				cout << v[j][k];
			}
			cout << endl;
		}
        //cout << endl;
	}
}
