using System;
using System.Text;
using System.Collections.Generic;

namespace AOJ2
{
    class Program
    {
        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;
            }

        }

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

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

            for (int i = 0; i < num; i++)
            {
                Console.ReadLine();
                bool[,] mas = new bool[8, 8];
                for (int j = 0; j < 8; j++)
                {
                    string input = Console.ReadLine();
                    for (int k = 0; k < 8; k++)
                    {
                        if (input[k] == '1')
                        {
                            mas[k, j] = true;
                        }
                        else
                        {
                            mas[k, j] = false;
                        }
                    }
                }

                int bombX = int.Parse(Console.ReadLine()) -1;
                int bombY = int.Parse(Console.ReadLine()) -1;

                Point firstBomb = new Point(bombX, bombY);

                resultList.Add(GetAfterBomb(mas, firstBomb));
            }


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


        }

        static bool[,] GetAfterBomb(bool[,] mas, Point firstBomb)
        {
            List<Point> bombList = new List<Point>();
            bombList.Add(firstBomb);

            while (bombList.Count != 0)
            {
                Point bomb = bombList[0];
                bombList.RemoveAt(0);

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

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

            }
            return mas;
        }
        
    }
}

Measured memory_bytes: 20044