def chk(mat,exp,y,x)
  if mat[y][x]==1
    exp.push([x,y])
    mat[y][x]=0
  end
  return mat,exp
end
ds,cnt=gets.to_i,0
ds.times do
  mat,=[],gets
  8.times{mat << gets.chomp.split("").map(&:to_i)}
  exp=[[gets.to_i-1,gets.to_i-1]]
  while !exp.empty?
    e=exp.pop
    mat[e[1]][e[0]]=0
    3.times do |i|
      mat,exp=chk(mat,exp,[e[1]-3+i,0].max,e[0])
      mat,exp=chk(mat,exp,e[1],[e[0]-3+i,0].max)
      mat,exp=chk(mat,exp,[e[1]+1+i,7].min,e[0])
      mat,exp=chk(mat,exp,e[1],[e[0]+1+i,7].min)
    end
  end
  puts "Data #{cnt+=1}:"
  mat.each{|i|
    puts i.join
  }
end