Problem G: Finding Prime Numbers #2

Problem G: Finding Prime Numbers #2

Time Limit: 1 Sec  Memory Limit: 128 MB
Submit: 0  Solved: 0
[Submit] [Status] [Web Board] [Creator:]

Description

A prime number is a number that is not divided evenly by any number other than 1 and itself.
For example, 2, 3, 5, and 7 are prime numbers because they are not divided evenly by any number other than 1 and themselves, but 4 is not a prime number because it is divided evenly by 2 in addition to 1 and itself.
Write a program that takes two numbers a and b as input and finds how many prime numbers are between a and b inclusive.

Input

First, input the number of test cases T (1 <= T <= 20).
Then, input a and b equal to T. (2 <= a < b <= 10,000)

Output

For each test case, output the number of prime numbers between a and b, one per line.

Sample Input Copy

3
2 10
50 100
100 1000

Sample Output Copy

4
10
143