def solve(data, x, y)
  range = -3..3
  if data[y][x] == 1
    data[y][x] = 0
    #横に走査
    range.each do |r|
      next if x + r < 0 || x + r > 7
      if data[y][x + r] == 1
        data = solve(data, x + r, y)
      end
    end
    #縦に走査
    range.each do |r|
      next if y + r < 0 || y + r > 7
      if data[y + r][x] == 1
        data = solve(data, x, y + r)
      end
    end
  end
  data
end

($stdin.gets.to_i).times do |t|
  $stdin.gets
  data = Array.new
  8.times do |i|
    data << $stdin.gets.chomp.split("").map(&:to_i)
  end

  x =$stdin.gets.to_i - 1
  y =$stdin.gets.to_i - 1
  printf "Data %d:\n", t + 1
  data = solve(data, x, y)
  8.times do |i| puts data[i].join
  end
end