#include <iostream>
#include <vector>
#include <memory>
struct Cell {
	static int i;
	const int id;
	Cell() :id(++i) {};
	virtual Cell *find() {
		return nullptr;
	}
	virtual void join(Cell &other) {}
	virtual bool is_blasted() const { return true; }
	virtual char name() const { return 'C'; }
	virtual char p_name() { return name(); }
	virtual int p_id() { return id; }
}; 
int Cell::i = 0;
struct Bomb :public Cell {
	Cell *u;
	Cell *find() override {
		if (u) {
			return u = u->find();
		}
		else {
			return this;
		}
	}
	void join(Cell &other) override {
		if (u) {
			u->join(other);
		}
		else {
			u = (other.find() == this) ? nullptr : other.find();
		}
	}
	bool is_blasted() const override {
		if (u) {
			return u->is_blasted();
		}
		else {
			return false;
		}
	}
	char name() const override { return 'B'; }
	char p_name() override {
		if (u) {
			return u->find()->p_name();
		}
		else {
			return name();
		}
	}
	int p_id() override { return find()->id; }
};
struct Fuse :public Cell {
	Cell *find() override {
		return this;
	}
	void join(Cell &other) override {
		if (&other != this) {
			other.join(*this);
		}
	}
	bool is_blasted() const override {
		return true;
	}
	char name() const override { return 'F'; }
};
int to_bin(const int &n) {
	if (n == 0)
		return 0;
	else
		return (to_bin(n / 10) << 1) + (n & 1);
}
void show(std::vector<std::shared_ptr<Cell>> &vec) {
	for (auto &v : vec) {
		std::cout << v->p_id();
	}
	std::cout << std::endl;
}
int main() {
	int n;
	std::cin >> n;
	for (auto i = 1; i <= n; ++i) {
		std::vector<std::vector<std::shared_ptr<Cell>>> vector(8, std::vector<std::shared_ptr<Cell>>(8));
		for (auto a = 0; a < 8; ++a) {
			int idx = 1 << 7;
			int in;
			std::cin >> in;
			in = to_bin(in);
			for (auto b = 0; b < 8; ++b) {
				if ((in & idx) != 0) {
					vector.at(a).at(b) = std::make_shared<Bomb>(Bomb());
				}
				else {
					vector.at(a).at(b) = std::make_shared<Cell>(Cell());
				}
				idx >>= 1;
			}
		}
		for (auto a = 0; a < 8; ++a) {
			for (auto b = 0; b < 7; ++b) {
				for (auto d = 1; d < ((8 - b < 4) ? (8 - b) : 4); ++d) {
					vector.at(a).at(b)->join(*vector.at(a).at(b + d));
					vector.at(b).at(a)->join(*vector.at(b + d).at(a));
				}
			}
		}
		Fuse fuse = Fuse();
		{
			int x, y;
			std::cin >> x >> y;
			vector.at(y - 1).at(x - 1)->join(fuse);
		}
		std::cout << "Data " << i << ":\n";
		for (const auto &vec : vector) {
			for (const auto &v : vec) {
				if (v->is_blasted()) {
					std::cout << 0;
				}
				else {
					std::cout << 1;
				}
				//std::cout << v->p_id() << "-";
			}
			std::cout << '\n';
		}
	}
}