This is (probably) the most easiest question of the problem set..!
You will be given a number say 'X'. You just have to find out one of its permutation that is divisible by 16.
Now this is to clarify what permutation means:
Suppose you are given 'X' as '123' then all possible permutations are: '123', '132', '213', '231', '312', '321'.
Just one twist though..
You need to output the lexicographically smallest permutation of 'X' that is divisible by 16.
Note: Your smallest permutation should not start with '0' (Technically, NO LEADING ZEROES ALLOWED...!!)
Note: If there are no such permutations that are divisible by 16 then, output "-1".
Input format:
First line contains 'X' as a string. All characters will be digits from 0 to 9 inclusive.
Output format:
Output "-1", if no such permutation exists.
else Output smallest permutation with no leading zeroes.
Constraints:
1 <= X <= 100. (Note that this means 'X' can be maximum '100' digits long number..!)