Problem list
Log in
#coci00339 · COCI 2014/2015 Contest 5

Zgodan

Platinum V 1.0 s 32 MB

An integer is considered handsome if every two of its consecutive digits are of different parity. For a given integer $N$, what is its closest handsome number? Please note: Numbers consisting of only one digit are handsome numbers. The distance of two numbers is the absolute value of their difference.

Input

The first and only line of input contains the positive integer $N$ that consists of at most thousand digits and is not handsome.

Output

The first and only line of output must contain the required closest handsome number. If two closest numbers exist, output the smaller number first and then the larger one and separate them by a single space.

Constraints

In test cases worth 56 points, it will hold $N < 10^{9}$.

Example 1

Input
13
5801001
Output
output
12 14
5810101
Source
COCI 2014/2015 Contest 5
Appears in
Not part of a ladder, contest or set yet.
Accepted 0 Submissions 0 Acceptance 0% Solvers 0

Discussion

Threads about this problem. Spoilers are collapsed; wrap hints in ||double bars||.

No discussion yet. Start a thread if something here needs explaining.

Recent submissions Open with filters
Code