Test cases not passing

here is code

Modified Code

mistake is that the ans is not in sorted order

so save all permutation in vector and sort the vector
and then print

now it pass all testcases