This line may limit the usefulness of this function in other situations.   It relies on each element of labels being divisible by K. For the purposes of this PR that will also be the case.