n = gets.to_i
n.times{|ii|
  gets
  mat = []
  8.times{|i|
    mat[i] = gets.chomp.split("").map(&:to_i)
  }
  x = gets.to_i - 1
  y = gets.to_i - 1
  q = []
  q << [y, x]
  while q.size > 0
    y, x = q.shift
    mat[y][x] = 0
    [-3,-2,-1,1,2,3].each{|dx|
      if x+dx < 0 || x+dx > 7
        next
      else
        if mat[y][x+dx] == 1
          q << [y,x+dx]
          mat[y][x+dx] = 0
        end
      end
    }
    [-3,-2,-1,1,2,3].each{|dy|
      if y+dy < 0 || y+dy > 7
        next
      else
        if mat[y+dy][x] == 1
          q << [y+dy,x]
          mat[y+dy][x] = 0
        end
      end
    }
  end
  puts "Data #{ii+1}:"
  8.times{|i|
    8.times{|j|
      print mat[i][j]
    }
    puts
  }
}