You have a word, and you can change the order of its letters however you like. Of all the possible results, which would be the third, in alphabetical order?
Input consists of several non-empty words , each with at most lowercase letters.
For every
,
among all the possible reorderings of its letters, print the third in
alphabetical order. If there is no such third word, print
“NO”.
Input
tca baba z
Output
cat abba NO