Range = (-3..3).map{|i| [[i,0], [0,i]]}.flatten(1) - [[0,0]]

def explode(x,y)
  @map[x][y] = "0"
  Range.each do |dx,dy|
    i,j = x+dx, y+dy
    next if !(0..7).include?(i) || !(0..7).include?(j)
    if @map[i][j] == "1"
      explode(i,j)
    end
    @map[i][j] = "0"
  end
end

n = gets.to_i
n.times do |dataset|
  gets
  @map = 8.times.map{ gets.chomp.chars }.transpose
  x,y = 2.times.map{ gets.to_i - 1 }
  explode(x,y)
  puts "Data #{dataset+1}:"
  puts @map.transpose.map(&:join)
end