Function to generate optimal covering of zeros in matrix