Divisible by 8
Medium
Execution time limit is 1 second
Runtime memory usage limit is 128 megabytes
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.
Examples
Input #1
Answer #1
Input #2
Answer #2
Input #3
Answer #3
Submissions 2K
Acceptance rate 7%