A. Sequence with Digits
time limit per test
1 secondmemory limit per test
256 megabytesinput
standard inputoutput
standard outputLet's define the following recurrence:
Here
and are the minimal and maximal digits in the decimal representation ofwithout leading zeroes. For examples refer to notes.
Your task is calculate
for given and.
Input
The first line contains one integer
) — the number of independent test cases.
Each test case consists of a single line containing two integers
and (,) separated by a space.
Output
For each test case print one integer
on a separate line.
Example
Input
Copy
8 1 4 487 1 487 2 487 3 487 4 487 5 487 6 487 7
Output
Copy
42 487 519 528 544 564 588 628
Note
No comments:
Post a Comment