| 2020-2021 ICPC, Moscow Subregional |
|---|
| Finished |
In the June of 2345 Bomboslav went to planet Nibiru for a summer internship as a barista in Bakefooc Inc. office there. As Bakefooc Inc. is a US-based company they continue to pay interns with cheques. Pay cheque is a paper document issued by an employer to pay an employee. Typically it is a piece of stamped paper with a sum and a signature of a head of payment department on it. You just bring this to any bank branch, wait for several days and enjoy the money being transferred to your account — what an easy and convenient way to be paid!
After two or three payments an evil plan came to Bomboslav's mind. What if he can scrap the upper layer of paper from the part where digits are written and stick them back in some order he might prefer more?
So he received his next pay cheque for $$$n$$$ nibidollars and successfully scrapped all the digits from it. He now wants to put them back in a following way.
What is the best result he can get? Note that he is not allowed to form the original integer $$$n$$$ if it was not divisible by $$$7$$$.
The only line of the input contains a single integer $$$n$$$ ($$$1 \leq n \lt 10^{1000}$$$) — the original sum in the pay cheque.
If there is a way to obtain at least one integer that satisfies all the requirements, print maximum such integer in the only line of the output. Otherwise, print -1.
14
14
11
-1
2020
2002
| Name |
|---|


