Lexicographical order is often known as alphabetical order when dealing with strings. A string is greater than another string if it comes later in a lexicographically sorted list.
Given a word, create a new word by swapping some or all of its characters. This new word must meet two criteria:
For example, given the word , the next largest word is .
Complete the function biggerIsGreater below to create and return the new string meeting the criteria. If it is not possible, return no answer.
Complete the biggerIsGreater function in the editor below. It should return the smallest lexicographically higher string possible from the given string or no answer.
biggerIsGreater has the following parameter(s):
The first line of input contains , the number of test cases.
Each of the next lines contains .
For each test case, output the string meeting the criteria. If no answer exists, print no answer.
Sample Input 0
Sample Output 0
Sample Input 1
Sample Output 1