Problem Tug of War

Can anyone tell me on which test case it is wrong
I am unable to find my mistake https://www.codechef.com/viewsolution/55304750

Hi, we need to print lexicographically smallest answer
For the test
2 8
6 2
1 49 34 39 9 14 16 19

Your code prints
YES
39 34 19 16 14 9 1 49

but actual answer is
YES
1 9 14 16 19 34 39 49