502. Digits Permutation
Time limit per test: 0.25 second(s)
Memory limit: 262144 kilobytes
input: standard
output: standard

Andrew has just made a breakthrough in the world of number 17: he realized that it's rather easy to permute the digits in almost any given number to get a number divisible by 17. You are given a positive integer n. You must find a permutation of its digits that is divisible by 17.
Input
Input file contains single integer n, 1 ≤ n ≤ 1017.
Output
Output any permutation of digits of n that is divisible by 17. The output permutation may not start with a zero. If there is no such permutation, output -1.
Example(s)
sample input
sample output
17
17

sample input
sample output
2242223
2222342

sample input
sample output
239
-1
