using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using static System.Math;

namespace CSharpSpiral {
    class Program {
        static void Main(string[] args) {
            var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);
            new Program().Solve(new ConsoleInput(Console.In, ' '));
            Console.Out.Flush();
        }
		public void Solve(ConsoleInput cin) {
			var questionCount = cin.ReadInt;
			for(int questionNum = 0; questionNum < questionCount; questionNum++) {
				var discarded = cin.ReadLine;
				var bombs = new bool[8, 8];
				var toBlow = new Queue<Tuple<int, int>>();
				for(int i = 0; i < 8; i++) {
					var line = cin.ReadLine;
					for(int j = 0; j < 8; j++) 
						bombs[i, j] = line[j] == '1';
				}
				var X = cin.ReadInt;
				var Y = cin.ReadInt;
				toBlow.Enqueue(Pair(Y - 1, X - 1));
				while(toBlow.Any()) {
					var blown = toBlow.Dequeue();
					int i = blown.Item1, j = blown.Item2;
					for(int dr = 1; dr <= 3; dr++) {
						if(j - dr >= 0 && bombs[i, j - dr]) toBlow.Enqueue(Pair(i, j - dr));
						if(j + dr< 8 && bombs[i, j + dr]) toBlow.Enqueue(Pair(i, j + dr));
						if(i - dr >= 0 && bombs[i - dr, j]) toBlow.Enqueue(Pair(i - dr, j));
						if(i + dr < 8 && bombs[i + dr, j]) toBlow.Enqueue(Pair(i + dr, j));
					}
					bombs[i, j] = false;
				}
				Console.WriteLine($"Data {questionNum + 1}:");
				for(int i = 0; i < 8; i++) {
					for(int j = 0; j < 8; j++) {
						Console.Write(bombs[i, j] ? "1" : "0");
					}
					Console.Write("\n");
				}

			}
		}

		public Tuple<int, int> Pair(int x, int y) => new Tuple<int, int>(x, y);

	}
	static class ExtendClass {
		public static string Join<T>(this IEnumerable<T> X, string separator = " ") => string.Join(separator, X);
	}
	class ConsoleInput {
		private readonly TextReader _stream;
		private readonly char _separator = ' ';
		private readonly Queue<string> inputStream;
		public ConsoleInput(TextReader stream, char separator = ' ') {
			this._separator = separator;
			this._stream = stream;
			inputStream = new Queue<string>();
		}
		public string Read {
			get {
				if(inputStream.Count != 0) return inputStream.Dequeue();
				string[] tmp = _stream.ReadLine().Split(_separator);
				for(int i = 0; i < tmp.Length; ++i)
					inputStream.Enqueue(tmp[i]);
				return inputStream.Dequeue();
			}
		}
		public string ReadLine { get { return _stream.ReadLine(); } }
		public int ReadInt { get { return int.Parse(Read); } }
		public long ReadLong { get { return long.Parse(Read); } }
		public double ReadDouble { get { return double.Parse(Read); } }
		public string[] ReadStrArray(long N) {
			var ret = new string[N];
			for(long i = 0; i < N; ++i)
				ret[i] = Read;
			return ret;
		}
		public int[] ReadIntArray(long N) { var ret = new int[N]; for(long i = 0; i < N; ++i) ret[i] = ReadInt; return ret; }
		public long[] ReadLongArray(long N) { var ret = new long[N]; for(long i = 0; i < N; ++i) ret[i] = ReadLong; return ret; }
		public double[] ReadDoubleArray(long N) { var ret = new double[N]; for(long i = 0; i < N; ++i) ret[i] = ReadDouble; return ret; }
	}
}



Measured memory_bytes: 18680