SP12150 JNEXT - Just Next !!!
Description
DevG likes too much fun to do with numbers. Once his friend Arya came and gave him a challenge, he gave DevG an array of digits which is forming a number currently (will be called as given number). DevG was challanged to find the just next greater number which can be formed using digits of given number. Now DevG needs your help to find that just next greater number and win the challenge.
Input Format
The first line have t number of test cases (1
Output Format
Print the just next greater number if possible else print -1 in one line for each test case.
**Note :** There will be no test case which contains zero in starting digits of any given number.