P17735 [HackerEarth] After Learning Prime Numbers, Dark want to revise the rules of composite numbers.
普及
题目描述

After Learning Prime Numbers, Dark want to revise the rules of composite numbers.

A composite number is a positive integer that has at least one positive divisor other than one or the number itself.

Read more about it: Composite Number .

He wants to generate all composite numbers between two given numbers but as you all are aware with Dark's Lucky number, 7 he wants to know only the composite numbers which have digit 7 in it.

Input

The first line contains T, the number of test cases.

Followed by T lines each contain two numbers M and N

Output

For every test case print the total count of composite numbers which contain 7 as a digit.

If no composite number with digit 7 between M and N
then print -1.

Separate the answers for each test case by an empty line.

Constraints

1 ≤ T ≤ 10000
1 ≤ M ≤ N ≤ 1000000

Author : Darshak Mehta

SAMPLE INPUT
3
1 9
14 37
1 6

SAMPLE OUTPUT
-1
1
-1

Explanation

Test Case 1:
Composite numbers between 1 to 9 are 4,6,8,9 and their is no number having digit 7.so output -1
Test Case 2:
Similarly for 14 to 37 we have 14,15,16,... but only 27 with digit 7 and a composite number. so output 1
Test Case 3:
No composite number with digit 7
so output -1.

输入格式

见题面

输出格式

见题面

样例输入
10 1 1000000 1 1000000 1 1000000 1 1000000 1 1000000 1 1000000 1 1000000 1 1000000 1 1000000 1 1000000
样例输出
425053 425053 425053 425053 425053 425053 425053 425053 425053 425053 425053 36132 2890 203 10 -1 -1 10 203 36132 425053 425053 425053 425053 425053 425053 425053 425053 425053 425053