A prime number is a positive number, which is divisible by exactly two diﬀerent integers.
A digit prime is a prime number whose sum of digits is also prime. For example the prime number 41 is a digit prime because 4 + 1 = 5 and 5 is a prime number. 17 is not a digit prime because 1 + 7 = 8, and 8 is not a prime number.
First line of the input ﬁle contains a single integer N (0 < N ≤ 500000) that indicates the total number of inputs. Each of the next N lines contains two integers t1 and t2 (0 < t1 ≤ t2 < 1000000).
For each line of input except the ﬁrst line produce one line of output containing a single integer that indicates the number of digit primes between t1 and t2 (inclusive).
3 10 20 10 100 100 10000
1 10 576
Note: You should at least use scanf() and printf() to take input and produce output for this problem. cin and cout is too slow for this problem to get it within time limit.
//使用Java的考生請注意，最外層的類別(class)需命名為 main 。