#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <cmath>
#include <memory.h>
#include <cassert>

using namespace std;


#define all(c) ((c).begin()), ((c).end())
#define debug(c) cerr << "> " << #c << " = " << (c) << endl;
#define iter(c) __typeof((c).begin())
#define present(c, e) ((c).find((e)) != (c).end())
#define cpresent(c, e) (find(all(c), (e)) != (c).end())
#define tr(i, c) for (iter(c) i = (c).begin(); i != (c).end(); i++)
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, a, b) for (int i = (int)(a); i <= (int)(b); i++)

#define mp make_pair
#define fst first
#define snd second
#define pb push_back


const double EPS = 1e-10;


typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef complex<double> P;


void go(int x, int y, vector<string> &m) {
	m[y][x] = '0';
	rep(i, 3) {
		if (y - i - 1 >= 0) if (m[y - i - 1][x] == '1') go(x, y - i - 1, m);
		if (y + i + 1 < 8) if (m[y + i + 1][x] == '1') go(x, y + i + 1, m);
		if (x - i - 1 >= 0) if (m[y][x - i - 1] == '1') go(x - i - 1, y, m);
		if (x + i + 1 < 8) if (m[y][x + i + 1] == '1') go(x + i + 1, y, m);
	}
}

int main() {
	int nCases; cin >> nCases;
	rep(iCase, nCases) {
		vector<string> m(8);
		rep(i, 8) cin >> m[i];
		int x, y; cin >> x >> y;
		x--;
		y--;
		go(x, y, m);
		cout << "Data " << iCase + 1 << ":" << endl;
		rep(i, 8) cout << m[i] << endl;
	}
	return 0;
}