#P9651. [SNCPC2019] Digit Product

[SNCPC2019] Digit Product

题目描述

Define the ''digit product'' f(x)f(x) of a positive integer xx as the product of all its digits. For example, f(1234)=1×2×3×4=24f(1234) = 1 \times 2 \times 3 \times 4 = 24, and f(100)=1×0×0=0f(100) = 1 \times 0 \times 0 = 0.

Given two integers ll and rr, please calculate the following value:

(i=lrf(i))mod(109+7)(\prod_{i=l}^r f(i)) \mod (10^9+7)

In case that you don't know what \prod represents, the above expression is the same as

$$(f(l) \times f(l+1) \times \dots \times f(r)) \mod (10^9+7) $$

输入格式

There are multiple test cases. The first line of the input contains an integer TT (about 10510^5), indicating the number of test cases. For each test case:

The first and only line contains two integers ll and rr (1lr1091 \le l \le r \le 10^9), indicating the given two integers. The integers are given without leading zeros.

输出格式

For each test case output one line containing one integer indicating the answer.

2
1 9
97 99

362880
367416

提示

For the first sample test case, the answer is 9!mod(109+7)=3628809! \mod (10^9+7) = 362880.

For the second sample test case, the answer is $(f(97) \times f(98) \times f(99)) \mod (10^9+7) = (9 \times 7 \times 9 \times 8 \times 9 \times 9) \mod (10^9+7) = 367416$.