Maurice Tutor

(5)

$15/per page/Negotiable

About Maurice Tutor

Levels Tought:
Elementary,Middle School,High School,College,University,PHD

Expertise:
Algebra,Applied Sciences See all
Algebra,Applied Sciences,Biology,Calculus,Chemistry,Economics,English,Essay writing,Geography,Geology,Health & Medical,Physics,Science Hide all
Teaching Since: May 2017
Last Sign in: 398 Weeks Ago, 2 Days Ago
Questions Answered: 66690
Tutorials Posted: 66688

Education

  • MCS,PHD
    Argosy University/ Phoniex University/
    Nov-2005 - Oct-2011

Experience

  • Professor
    Phoniex University
    Oct-2001 - Nov-2016

Category > Computer Science Posted 16 Sep 2017 My Price 7.00

Matt's little brother Paul

Young Matt and Jeff loved playing with numbers. One fine day, when Matt's little brother Paul, was at his math lesson with plastic number toys i.e. plastic toys in shape of digits 0 to 9, Matt and Jeff decided to play a game.
Paul had left the plastic numbers arranged to form a number N.
The rules of the game were as follows:

  • The first player has to rearrange the digits to form a larger number than the current number, after that the game will be played turn-wise.
  • After the first turn, each player has to rearrange the digits so that it is smaller than the current number in that turn and greater than the original number N.
  • The player loses if he cannot arrange a number.

What number should the first player form, so that he always wins?

Input

An integer T (1 = T = 100) denoting number of test cases followed by T lines each containing an integer N, the number Paul has formed. The number of digit in N is D(1 = D = 100000).

Output

For each test case, output a number which first player should form so that he wins, in a separate line.
If there is no winning strategy for first player, then output -1.

Example

Input: 3 17 81 123 Output: 71 -1 132

Answers

(5)
Status NEW Posted 16 Sep 2017 03:09 PM My Price 7.00

Hel-----------lo -----------Sir-----------/Ma-----------dam-----------Tha-----------nk -----------You----------- fo-----------r u-----------sin-----------g o-----------ur -----------web-----------sit-----------e a-----------nd -----------and----------- ac-----------qui-----------sit-----------ion----------- of----------- my----------- po-----------ste-----------d s-----------olu-----------tio-----------n.P-----------lea-----------se -----------pin-----------g m-----------e o-----------n c-----------hat----------- I -----------am -----------onl-----------ine----------- or----------- in-----------box----------- me----------- a -----------mes-----------sag-----------e I----------- wi-----------ll

Not Rated(0)