POJ#1731 next permutation. Rank:8021