9000: World Fragments III

内存限制:128 MB 时间限制:1 S
题面:传统 评测方式:文本比较 上传者:
提交:1 通过:0

题目描述


This problem is different from World Fragments I and World Fragments II. Please read the statements carefully.
There are qqq queries for you to answer.
For each query, you are given two non-negative decimal integers xxx and yyy without leading zeros. You can apply the following operation to xxx any number of times (possibly zero):
  1. Choose a digit bbb in xxx.
  2. Let either x←x+bx \gets x + bxx+b or x←x−bx \gets x - bxxb.
For example, when x=(616)10x = (616)_{10}x=(616)10 you can choose the digit b=(1)10b=(1)_{10}b=(1)10 in (61‾6)10(6\underline{1}6)_{10}(616)10, then let x←x−b=(616)10−(1)10=(615)10x \gets x - b = (616)_{10} - (1)_{10} = (615)_{10}xxb=(616)10(1)10=(615)10.
Find out the least number of operations needed to turn xxx into yyy. Since the answer can be very large, output it modulo 998244353998\,244\,353998244353. Print −1-11 if it is impossible to turn xxx into yyy.

输入格式


The first line contains a positive integer TTT (1≤T≤1031\leq T\leq 10^31T103) — the number of queries.
Each query consists of a line that contains two integers x,yx, yx,y (0≤x≤y≤101060\leq x\le y\leq 10^{10^{6}}0xy10106). Please note that in this version, x≤yx\le yxy.
It is guaranteed that the sum of the lengths of the decimal representations of all yyys does not exceed 2×1062\times10^{6}2×106.

输出格式

For each query, print a decimal integer in a single line, denoting the answer modulo 998244353998\,244\,353998244353. If it is impossible to turn xxx into yyy, print −1-11.

输入样例 复制

4
1 7
1 9
13 23
123456789 987654321

输出样例 复制

-1
6
8
102755278