CF2067A.Adjacent Digit Sums

传统题 时间 2000 ms 内存 256 MiB 3 尝试 1 已通过 1 标签

Adjacent Digit Sums

You are given two numbers x,yx, y. You need to determine if there exists an integer nn such that S(n)=xS(n) = x, S(n+1)=yS(n + 1) = y.

Here, S(a)S(a) denotes the sum of the digits of the number aa in the decimal numeral system.

Input

Each test contains multiple test cases. The first line contains the number of test cases tt (1t5001 \le t \le 500). The description of the test cases follows.

The first line of each test case contains two integers x,yx, y (1x1000,1y10001 \le x \le 1000, 1 \le y \le 1000).

Output

For each test case, print "NO" if a suitable nn does not exist. Otherwise, output "YES".

You can output each letter in any case (for example, "YES", "Yes", "yes", "yEs", "yEs" will be recognized as a positive answer).

Note

In the first test case, for example, n=100n = 100 works. S(100)=1S(100) = 1, S(101)=2S(101) = 2.

In the second test case, it can be shown that S(n)S(n+1)S(n) \neq S(n+1) for all nn; therefore, the answer is No.

In the fourth test case, n=101111n = 10^{111}-1 works, which is a number consisting of 111111 digits of 99.

Samples

7
1 2
77 77
997 999
999 1
1000 1
1 11
18 1
Yes
No
No
Yes
No
No
Yes

在线编程 IDE

建议全屏模式获得最佳体验