def leftmostNonzeroEntries(M):
  """Returns the leftmost nonzero entries of M."""
  return [ abs(M[l][M.nonzero_positions_in_row(l)[0]])
           for l in range(0,M.dimensions()[0])
           if M.nonzero_positions_in_row(l) != [] ]