spoj#GONE. G-One Numbers
G-One Numbers
The War of Evil vs Good continues and Ra-One and G-One continue to be on respective sides.
After saving all the cities with Ra-One Numbers G-One realised that some cities whose population is a "G-One Number" can be easy target for Ra-One.
A G-One number is a number sum of whose digits is a prime number
For eg. 12 .. sum = 1+2 =3 ... 3 is a prime number.
G-One wants to find out all the populations which can be g-One numbers....
Can You help Him.?
You will be given the range of population and you have to tell him how many in this range are G-One Numbers.
Input
first line has number 'c' indicating the number of ranges.
'c' lines follow and contain two numbers ..... 'f' and 't' inclusive.
Output
Print a single line per case giving the number of populations which are G-One numbers.
Example
Input: 3
10 19
1 9
20 29
Output:
4
4
5
Note: c will be less than 100
t and f will be less than 10^8 inclusive