Miaomiao's Function

Time Limit: 1000ms
Memory Limit: 65536KB
This problem will be judged on HDU. Original ID: 4933
64-bit integer IO format: %I64d      Java class name: Main

Description

Firstly , Miaomiao define two functions f(x) , g(x):


(K is the smallest integer which satisfied x + 9 * K > 0)

if e.g. g(178) = 1 - 7 + 8 = 2 , g(1) = 1 , g(1234) = 1 - 2 + 3 - 4 = -2;

For example f(20140810) = f(2 + 0 + 1 + 4 + 0 + 8 + 1 + 0) = f(16) = f(1 + 6) = f(7) = 7

Then , you are given two integers L , R( L <= R) .
Answer is defined as .
Please caculate (Answer Mod f(Answer) + f(Answer)) Mod f(Answer).
Pay attantion ! If f(Answer) = 0 , please output "Error!"

Input

There are many test cases. In the first line there is a number T ( T <= 50 ) shows the number of test cases.
For each test cases there are two numbers L ,R ( 0 <= L,R <= 10^100 ).

For your Information , L , R don't have leading zeros.

Output

For each opeartion , output the result.

Sample Input

2
0 0
0 21

Sample Output

Error!
1

Source

Language: 
Theme: 
Share Code? 

Powered by NB231 | Current Style: .