#define _CRT_SECURE_NO_WARNINGS
#include"bits/stdc++.h"
#ifdef _DEBUG
#define DBG(n) n
#else
#define DBG(n)
#endif
#define INF         1e9
#define INFLL       1e18
#define EPS         1e-9
#define REP(i,n)    for(ll i=0,i##_len=(n);i<i##_len;++i)
#define REP1(i,n)   for(ll i=1,i##_len=(n);i<=i##_len;++i)
#define REPR(i,n)   for(ll i=(n)-1;i>=0;--i)
#define REPR1(i,n)  for(ll i=(n);i>0;--i)
#define REPC(i,obj) for(auto i:obj)
#define ALL(obj)    (obj).begin(),(obj).end()
#define SETP(n)     cout << fixed << setprecision(n)
using namespace std;
using ll = long long;
template<typename T = ll>inline T in() { T ret; cin >> ret; return ret; }

signed main()
{
	ll n = in();
	array<array<char, 8>, 8>g;
	REP(i, n) {
		REP(j, 8)REP(k, 8) g[j][k] = in<char>();
		ll X = in() - 1, Y = in() - 1; queue<pair<ll, ll>>bombs; bombs.push(make_pair(X, Y));
		while (!bombs.empty()) {
			ll x = bombs.front().first, y = bombs.front().second; bombs.pop(); g[y][x] = '0';
			REP1(j, 3) {
				if (x + j >= 8)break;
				if (g[y][x + j] == '1')bombs.push(make_pair(x + j, y));
				g[y][x + j] = '0';
			}
			REP1(j, 3) {
				if (y - j < 0)break;
				if (g[y - j][x] == '1')bombs.push(make_pair(x, y - j));
				g[y - j][x] = '0';
			}
			REP1(j, 3) {
				if (x - j < 0)break;
				if (g[y][x - j] == '1')bombs.push(make_pair(x - j, y));
				g[y][x - j] = '0';
			}
			REP1(j, 3) {
				if (y + j >= 8)break;
				if (g[y + j][x] == '1')bombs.push(make_pair(x, y + j));
				g[y + j][x] = '0';
			}
		}
		cout << "Data " << i + 1 << ':' << endl;
		REP(j, 8) {
			REP(k, 8) {
				cout << g[j][k];
			}
			cout << endl;
		}
	}
}
