Love is PRIME

4

2 votes
Easy
Problem

Buddy is known for his love for primes. He claims that if given a number he can instantly tell wether it is a prime or not. Golu challneges his this claim and gives Buddy 2 numbers X and Y, Q times and asks him to tell the number of primes between X and Y(X and Y included). Buddy lately has been quite rusty with his knowledge of primes as he is out of practice and hence asks for your help so that he can prove his claim right. Help him to tell count of primes from  X to Y.

Constraints:

1 ≤ Q ≤ 105
1 ≤ XY≤ 107
0 ≤ YX ≤ 103

Input:
First line of the input contains the number Q, Each of the next Q lines contain 2 numbers X and Y.

Output:

For each given X and Y, print the count of number which are prime between X and Y (X and Y included) in a new line.

Sample Input
5
1 5
7 11
8 8
13 13
10 15
Sample Output
3
2
0
1
2
Time Limit: 2
Memory Limit: 256
Source Limit:
Explanation

There are 3 prime number between 1 and 5 which are 2, 3 and 5.

There are 2 prime number between 7 and 11 which are 7 and 11.

Editor Image

?