Codeforces Round 762 (Div. 3) |
---|
Finished |
Tanya is learning how to add numbers, but so far she is not doing it correctly. She is adding two numbers $$$a$$$ and $$$b$$$ using the following algorithm:
For example, the numbers $$$a = 17236$$$ and $$$b = 3465$$$ Tanya adds up as follows:
$$$$$$ \large{ \begin{array}{r} + \begin{array}{r} 17236\\ 03465\\ \end{array} \\ \hline \begin{array}{r} 1106911 \end{array} \end{array}} $$$$$$
As a result, she gets $$$1106911$$$.
You are given two positive integers $$$a$$$ and $$$s$$$. Find the number $$$b$$$ such that by adding $$$a$$$ and $$$b$$$ as described above, Tanya will get $$$s$$$. Or determine that no suitable $$$b$$$ exists.
The first line of input data contains an integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases.
Each test case consists of a single line containing two positive integers $$$a$$$ and $$$s$$$ ($$$1 \le a \lt s \le 10^{18}$$$) separated by a space.
For each test case print the answer on a separate line.
If the solution exists, print a single positive integer $$$b$$$. The answer must be written without leading zeros. If multiple answers exist, print any of them.
If no suitable number $$$b$$$ exists, output -1.
6 17236 1106911 1 5 108 112 12345 1023412 1 11 1 20
3465 4 -1 90007 10 -1
The first test case is explained in the main part of the statement.
In the third test case, we cannot choose $$$b$$$ that satisfies the problem statement.
Name |
---|