import std.stdio;
import std.conv;
import std.string;
import std.typecons;
import std.algorithm;
import std.array;
import std.range;
import std.math;
import std.container;

void main()
{
	auto n = readln.chomp.to!int;
	foreach (c; 1..n+1) {
		readln;
		auto area = new char[][](8, 8);
		foreach (i; 0..8) {
			area[i] = readln.chomp.map!(to!char).array;
		}
		auto y = readln.chomp.to!int - 1;
		auto x = readln.chomp.to!int - 1;

		void solve(int i, int j) {
			area[i][j] = '0';
			foreach (h; max(i-3,0)..min(i+4, 8)) {
				if (area[h][j] == '1') solve(h, j);
			} 
			foreach (w; max(j-3,0)..min(j+4, 8)) {
				if (area[i][w] == '1') solve(i, w);
			} 
		}
		solve(x, y);

		writeln("Data ", c, ":");
		foreach (i; 0..8) {
			foreach (j; 0..8) {
				write(area[i][j]);
			}
			writeln("");
		}
	}
}