import java.util.*;
public class Main {
public static void main(String args[]) {
Scanner cin = new Scanner(System.in);
int n = cin.nextInt();
int arr[] = new int[1000005];
// System.out.print(arr[0]);
primeSieve(arr);
while (n-- > 0) {
int count = 0;
int a = cin.nextInt(), b = cin.nextInt();
for (int i = a; i <= b; i++) {
if (arr[i] == 1) {
count++;
}
}
System.out.println(count);
}
}
public static void primeSieve(int[] prime) {
for(int i=2;i<prime.length;i++)
prime[i] = 1;
for(int p = 2; p <prime.length; p++)
{
// If prime[p] is not changed, then it is a prime
if(prime[p] == 1)
{
// Update all multiples of p
for(int i = p; i < prime.length; i += p)
prime[i] = 0;
}
}
}
}
where i went wrong in the code i am stuck up and on comiling it is showing 0 as output on running