Lucky Numbers Again

All submissions for this problem are available.
A lucky number N is defined as a number which has only two factors, both of them distinct and prime and the absolute difference between the two factors is not more than 50.
Given two integers, a and b, find the total lucky numbers in the range a to b (inclusive).
Input
1.The first input will be T, the number of testcases. T <= 2000. T lines follow, one for each test case.
2.For each test case there are two integers a and b on each line. 1 <= a <= b <= 100000
Output
For every test case, print the number of lucky numbers from a to b (inclusive).
Example
Input: 1 1 20
Output: 4
Explanation From 1 to 20, there are four lucky numbers, 6,10, 14, and 15.
Author:  csirubix 
Tags  csirubix 
Date Added:  13022010 
Time Limit:  1 sec 
Source Limit:  50000 Bytes 
Languages:  ADA, ASM, BASH, BF, C, C99 strict, CAML, CLOJ, CLPS, CPP 4.3.2, CPP 4.9.2, CPP14, CS2, D, ERL, FORT, FS, GO, HASK, ICK, ICON, JAVA, JS, LISP clisp, LISP sbcl, LUA, NEM, NICE, NODEJS, PAS fpc, PAS gpc, PERL, PERL6, PHP, PIKE, PRLG, PYPY, PYTH, PYTH 3.4, RUBY, SCALA, SCM chicken, SCM guile, SCM qobi, ST, TEXT, WSPC 
Comments
 Please login at the top to post a comment.
SUCCESSFUL SUBMISSIONS
Fetching successful submissions
HELP
If you are still having problems, see a sample solution here. 