#d2847. 素数之欢
素数之欢
素数之欢
题目描述
现给定两个 四位素数 。 你可以执行多次下面的操作:
修改数字 的某一位, 使其成为另一个 四位素数。
例如,,其中 与 均为素数。
问至少多少次变换后能从 得到 ? 或回答不可能。
输入格式
第一行一个数字 ,表示接下来将会有 组数据。
接下来包含 行,每行包含用空格分开的两个 四位素数 。
输出格式
输出 行,如果可以,输出最小变换次数。反之输出 。
样例输入
2
1033 1033
1033 8779
样例输出
0
5
样例解释
$$1033 \rightarrow 1\textbf{7}33 \rightarrow \textbf{3}733 \rightarrow 373\textbf{9} \rightarrow 37\textbf{7}9 \rightarrow \textbf{8}779$$tips: you only operate times if possible.
数据范围
- 多组数据