using System;
using System.Collections.Generic;

namespace _0071
{
    class Program
    {
        static void Main(string[] args)
        {
            List<bool[,]> resultList = new List<bool[,]>();

            int numberOfData = int.Parse(Console.ReadLine());

            for (int i = 0; i < numberOfData; i++)
            {
                Console.ReadLine();

                bool[,] squares = new bool[8, 8];

                for (int y= 0; y < 8; y++)
                {
                    string input = Console.ReadLine();
                    for (int x = 0; x < 8; x++)
                    {
                        if (input[x] == '1')
                        {
                            squares[x, y] = true;
                        }
                        else
                        {
                            squares[x, y] = false;
                        }
                    }
                }
                int bombX = int.Parse(Console.ReadLine()) - 1;
                int bombY = int.Parse(Console.ReadLine()) - 1;                                
                resultList.Add(GetSquaresAfterBomb(squares, bombX,bombY));
            }

            int count = 1;
            foreach (bool[,] squares in resultList)
            {
                Console.WriteLine("Data {0}:", count);
                for (int y = 0; y < 8; y++)
                {
                    for (int x = 0; x < 8; x++)
                    {
                        if (squares[x, y])
                        {
                            Console.Write("1");
                        }
                        else
                        {
                            Console.Write("0");
                        }
                    }
                    Console.WriteLine();
                }
                count++;
            }
        }

        static bool[,] GetSquaresAfterBomb(bool[,] squares, int bombX,int bombY)
        {
           var bombList = new List<Point>();
            bombList.Add(new Point(bombX, bombY));

            while (bombList.Count != 0)
            {
                Point bomb = bombList[0];
                bombList.RemoveAt(0);
                squares[bomb.x, bomb.y] = false;
                for (int x = bomb.x - 3; x <= bomb.x + 3; x++)
                {
                    if (x >= 0 && x <= 7 && squares[x, bomb.y])
                    {
                        bombList.Add(new Point(x, bomb.y));
                        squares[x, bomb.y] = false;
                    }
                }

                for (int y = bomb.y - 3; y <= bomb.y + 3; y++)
                {
                    if (y >= 0 && y <= 7 && squares[bomb.x, y])
                    {
                        bombList.Add(new Point(bomb.x, y));
                        squares[bomb.x, y] = false;
                    }
                }
            }
            return squares;
        }

        class Point
        {
            public int x { get; set; }
            public int y { get; set; }
 
            public Point()
            {
                this.x = 0;
                this.y = 0;
            }
 
            public Point(int x, int y)
            {
                this.x = x;
                this.y = y;
            }
        }
    }
}

Measured memory_bytes: 20104