Problems
Divisible by 8
Divisible by 8
Given big integer n. Can you rearrange its digits so that the resulting number is divisible by 8? If there are multiple answers, print the smallest. Do not print the leading '0'.
Input
One big integer n (1 ≤ |n| ≤ 1000, where |n| denotes the number of digits in number n, n ≥ 1)
Output
If the solution does not exist, print -1. Otherwise print the required minimum number.
Input example #1
8
Output example #1
8
Input example #2
5
Output example #2
-1
Input example #3
24
Output example #3
24