solve next permutation