<PREV Problem:
NEXT>
Solved by 722 users: ...
 < 
 < 
 < 
 < 
 < 
 < 
 < 
 < 
 < 
 < 

Next word

Time limit = 2 second(s)

Somewhere in the world exist L ( L ≤ 200 ) cards, each of them has some latin letter written on it. This cards are put together to form a word of length L. The problem is to find the next word in the lexicographical order which can be formed of all those cards.

Input. Word of latin letters in the lower case.

Output. Next (in lexicographical order) word.

If the required word can not be found, output 'no word'.

Input#1
abca
Output#1
acab

Input#2
aaa

Output#2
no word

Author:
Kvasov Igor, folklore

<PREV | Problem set | Search related messages | NEXT>


© acm.mipt DevGroup
The page was generated in 190ms

SW soft NIX
ID = 54.198.246.116