Problem
Let us call an integer interesting if the product of its digits is divisible by the sum of its digits. You are given two integers and . Find the number of interesting integers between and (both inclusive).
Input
The first line of the input gives the number of test cases, . lines follow.
Each line represents a test case and contains two integers: and .
Output
For each test case, output one line containing Case #:
, where is the test case number (starting from 1) and is the number of interesting integers between and (inclusive).
Limits
Time limit: 20 seconds.
Memory limit: 1 GB.
.
Test Set 1
.
Test Set 2
.
Sample
4 1 9 91 99 451 460 501 1000
Case #1: 9 Case #2: 0 Case #3: 5 Case #4: 176
In Sample Case #1, since the product and the sum of digits are the same for single-digit integers, all integers between and are interesting.
In Sample Case #2, there are no interesting integers between and .
In Sample Case #3, there are five interesting integers between and :
- (product of its digits is , sum of its digits is ).
- (product of its digits is , sum of its digits is ).
- (product of its digits is , sum of its digits is ).
- (product of its digits is , sum of its digits is ).
- (product of its digits is , sum of its digits is ).
ConversionConversion EmoticonEmoticon