P17646 [IO 2025 #1] New Game

Description

While traveling around Pharloom, Hornet meets a strange beetle. It agrees to help Hornet, but only if she beats it in a strange game. The rules of the game are as follows: 1. The beetle first gives two positive integers $a$ and $b$. 2. Then it asks Hornet: does there exist a non-negative integer $c$ such that $a+c$ is a substring of $b+c$? Here, "number $x$ is a substring of number $y$" means that the decimal representation of $x$ is exactly equal to some contiguous block of digits in the decimal representation of $y$. Hornet really wants to win. Help her find such a $c$, or determine that no such number exists.

Input Format

The first line contains an integer $a$ with $1\le a\le 10^{10000}$. The second line contains an integer $b$ with $1\le b\le 10^{10000}$.

Output Format

If there exists a valid $c$ whose decimal representation has length at most $20000$, output such a number. If there are multiple answers, output any one of them. If no valid $c$ exists, output `-1`.

Explanation/Hint

Translated by QwenWork