require 'pp'
class Solve
  attr_reader :map

  def initialize(map)
    @map = map.dup
  end

  def bomb(x, y)
    @map[x][y] = 0

    (-3).upto(3) do |i|
      _x, _y = x + i, y + i

      next if _x < 0 || _x >= 8

      if @map[_x][y] == 1
        bomb(_x, y)

        @map[_x][y] = 0
      end

      next if _y < 0 || _y >= 8

      if @map[x][_y] == 1
        bomb(x, _y)

        @map[x][_y] = 0
      end
    end
  end
end

n = gets.to_i
n.times do |i|
  gets

  map = []
  8.times do
    map.push(gets.chomp.split(//).map(&:to_i))
  end
  map = map.transpose

  x, y = gets.to_i - 1, gets.to_i - 1

  solve = Solve.new(map)
  solve.bomb(x, y)

  puts "Data #{i + 1}:"
  solve.map.transpose.each do |line|
    puts line.join('')
  end
end