Server Time: Thu Oct 1, 2020 10:43 pm
 Welcome ( logout )
E - Very Lucky Numbers
 PDF (English) Ranklist
 Time Limit: 3 second(s) Memory Limit: 32 MB

According to some theory 4 and 7 are lucky digits, and all the other digits are not lucky. A lucky number is a number that contains only lucky digits in decimal notation. A very lucky number is a number that can be expressed as a product of several lucky numbers. A lucky number by itself is considered to be very lucky. For example, numbers 47, 49, 112 are very lucky.

Your task is to calculate the number of very lucky numbers that are not less than A and not greater than B.

# Input

Input starts with an integer T (≤ 8000), denoting the number of test cases.

Each case starts with a line containing two integers A and B (1 ≤ A ≤ B ≤ 1012).

# Output

For each case, print the case number and the result.

4

1 2

88 99

112 112

1 100

Case 1: 0

Case 2: 0

Case 3: 1

Case 4: 10

# Note

Very lucky numbers for the last sample input are 4, 7, 16, 28, 44, 47, 49, 64, 74 and 77.

 Developed and Maintained by JANE ALAM JAN Copyright © 2012 LightOJ, Jane Alam Jan