#P7662. [COCI 2014/2015 #5] ZGODAN

[COCI 2014/2015 #5] ZGODAN

Description

Define a Handsome number: in this positive integer, the parity of any two adjacent digits is different.

Given a positive integer nn, find the Handsome number closest to nn. If there are multiple answers, output them in increasing order.

Input Format

A positive integer nn.

Output Format

The Handsome number(s) closest to nn.

13
12 14
5801001
5810101

Hint

For 100%100\% of the testdata, 1n1010001 \leq n \leq 10^{1000}.

Translated from COCI 2014/2015 CONTEST #5.

Translated by ChatGPT 5