n = gets.to_i

n.times do |vez|
  gets.chomp
  map = []
  8.times do
    map << gets.chomp.chars.map(&:to_i)
  end
  x = gets.to_i - 1
  y = gets.to_i - 1

  current_bomb = [y, x]

  until current_bomb.empty?
    x = current_bomb.pop
    y = current_bomb.pop
    
    -3.upto(3) do |i|
      if (0..7).include?(x+i) && map[y][x+i] == 1
        current_bomb.push(y)
        current_bomb.push(x+i)
        map[y][x+i] = 0
      end
      if (0..7).include?(y+i) && map[y+i][x] == 1
        current_bomb.push(y+i)
        current_bomb.push(x)
        map[y+i][x] = 0
      end
    end
  end

  puts "Data #{vez+1}:"
  8.times { |i| puts map[i].join }
end