## The Mirror

View as PDF

Points: 5
Time limit: 1.0s
Memory limit: 64M

Author:
Problem type

Christine Daaé was kidnapped one night while singing on stage. Raoul, with the aid of the Persian, discovered that the Phantom was the kidnapper. The Persian believed that the easiest way to get to the Phantom's hiding place, which is on the lake under the Paris Opera House, in case you wonder, is from Christine's dressing room. On the corners of the mirror inside the dressing room were two numbers. The Persian recounted that the Phantom liked prime numbers, and the only way to open the secret passage behind the mirror is to knock on the mirror. The exact amount of times to knock is determined by the number of prime numbers between the two numbers shown, as a left-closed, right-open bounded interval. Since Christine's life is in danger, they expect you to solve it in one second, programmatically of course.

The Persian enlightens you on left-closed, right-open bounded intervals, because he fears that you will do it wrong and lose valuable time. An interval is an interval from to including but excluding , and is described as left-closed, right-open bounded interval.

But really, they just threatened to show the Phantom's fa^U

#### Input Specification

The first line is the number , such that , the number of test cases to follow. The next lines are two numbers, as written on the mirror, which are guaranteed to be no more than 500.

#### Output Specification

Output the number of times they need to knock to open up the secret passage behind the mirror.

#### Sample Input

2
1 10
1 100

#### Sample Output

4
25

#### Explanation

• There are 4 primes in : 2, 3, 5, 7.
• There are 25 primes in : 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97.