2749. Lucky numbers

单点时限: 5.0 sec

内存限制: 256 MB

John has recently arrived in Bucharest for the South Eastern European Regional Contest. John is famous for his theory of lucky numbers. That’s why all the contestants and spectators are very happy.

According to that 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. Of course, numbers A and B are given by John.

输入格式

The first line of the input contains a single integer T – a number of test cases. Each of the next T lines contains two integers separated by a single space – A and B.

输出格式

Output must contain T lines – answers for the test cases.

Constrains:

1 ≤ T ≤ 7777,

1 ≤ A ≤ B ≤ 1000000000000 (1012).

样例

Input
4
1 2
88 99
112 112
1 100
Output
0
0
1
10

2 人解决,8 人已尝试。

3 份提交通过,共有 24 份提交。

9.6 EMB 奖励。

创建: 14 年,6 月前.

修改: 6 年,8 月前.

最后提交: 9 月,3 周前.

来源: Southeastern European Regional Programming Contest 2008

题目标签