P16209 [ECUSTPC 2025] Seeing Is Believing.

Description

Maddy and Baddy are having a battle of minds. Baddy has a hidden number $a$ in mind, and $a$ satisfies the following rules: - $a$ is a natural number. - $l \le a < l + 6$. - The remainder when $a$ is divided by $2$ is $m_2$, and the remainder when $a$ is divided by $3$ is $m_3$. Now Maddy knows $l, m_2, m_3$. Please help her find a possible value of $a$ that Baddy might be thinking of. If no possible answer exists, report that there is no solution.

Input Format

One line contains $3$ integers $l, m_2, m_3$ ($0 \le l \le 100, 0 \le m_2 < 2, 0 \le m_3 < 3$), representing the range of Baddy’s number, the remainder when divided by $2$, and the remainder when divided by $3$, respectively.

Output Format

If a valid answer exists, output one integer $a$ in one line, representing the number Baddy is thinking of. If there are multiple valid answers, you may output any one of them. If no possible answer exists, output one integer $-1$ in one line.

Explanation/Hint

### Explanation for Sample 1 Check the above properties one by one: - $5$ is a natural number. - $0 \le 5 < 0 + 6$. - The remainder when $5$ is divided by $2$ is $1$, and the remainder when $5$ is divided by $3$ is $2$. Therefore, $5$ satisfies the conditions of the number Baddy is thinking of, and it is a possible value. ### Hint $0$ is a natural number. Translated by ChatGPT 5