next permutation with duplicate