|Author:||A. Usmanov||Time limit:||1 sec|
|Input file:||input.txt||Memory limit:||256 Mb|
Arocdnicg to rsceearch at Cmabrigde Uinervtisy, it deosn’t mttaer in waht oredr the ltteers in a wrod are, the olny iprmoatnt tihng is taht the frist and lsat ltteer are in the rghit pcale. The rset can be a toatl mses and you can sitll raed it wouthit pobelrm. Tihs is buseace the huamn mnid deos not raed ervey lteter by istlef, but the wrod as a wlohe.
Alexey decided to test whether this property will also hold for integers. He picked an integer number N and now wants to rearrange its digits so that:
Additionally for each position except the first and the last one, digits located in this position before and after rearrangement must be different.
You program must rearrange digits of a given integers according to Alexey's requirements.
Input file contains a single integer N.
Output file must contain a single integer — an answer to the problem. If there are several solutions, output any of them.
If there is no solution, output − 1.
1 ≤ N ≤ 109
|No.||Input file (
||Output file (|