#C1420. Largest Even Number

    ID: 43823 Type: Default 1000ms 256MiB

Largest Even Number

Largest Even Number

You are given a string of decimal digits. Your task is to rearrange all these digits to form the largest possible even number. An even number is one that ends with an even digit (i.e. one of \(0, 2, 4, 6, 8\)).

If it is impossible to form an even number using all the digits, output \(-1\). In other words, let \(S\) be the string of digits provided. You need to find a permutation \(P\) of all characters of \(S\) such that:

[ P\text{ mod }2 = 0 \quad \text{ and } \quad P \text{ is maximum possible.} ]

Note: The final number must use all the digits from the input exactly once.

inputFormat

The input consists of a single line containing a non-empty string of digits. This string is given via standard input (stdin).

outputFormat

Print the largest even number that can be formed by rearranging all the given digits. If no even number can be formed, print -1. Write your answer to standard output (stdout).

## sample
24853
85432