Company: flipkart_27feb
Difficulty: medium
Inside a mobile game, a player receives a batch of strings and must rearrange the letters of each one so the new arrangement is the very next one that would appear after it in dictionary (lexicographic) order. Write a program that does this rearranging for the player. Whenever no later arrangement exists, print "no changes" instead. Read the input from STDIN and print the output to STDOUT. Do not print arbitrary strings anywhere in the program, as these contribute to the output and test cases will fail. Constraints: 1 < n < 10000, the number of strings in each test case. Each string contains letters in range from [a...z] only Input format: The first line of input contains n Next n lines contain a string each Output format: For each input string, print the rearranged string satisfying the rule above, or print "no changes" if no such rearrangement exists. Sample Input 1: 3 dcab dd bca Sample Output 1: dcba no changes cab Explanation 1: For the first string 'dcab', rearranging the l