#include<stdio.h>
int main()
{
int t,m,n;
scanf("%d",&t); // number of test cases
while(t>0)
{
scanf("%d%d",&m,&n);
int prime[n]; // for finding prime numbers
int listofprime[n]; // for storing only prime numbers
int pos=0;
for(int i=2;i<=n;i++) //declare all to 1
prime[i]==1;
prime[0]==0;
prime[1]==0;
for(int i=2;i*i<=n;i++) //simple sieve to find primes till sqrt(n)
{
if(prime[i]==1)
{
listofprime[pos]=i;
pos++;
for(int mult=2;i*mult<=n;mult++)
prime[i*mult]==0;
}
}
for(int i=0;listofprime[i]*listofprime[i]<=n;i++) //segmented sieve
{
int low=m/listofprime[i];
low*=listofprime[i];
for(int j=low+listofprime[i];j<=n;j+=listofprime[i])
prime[j]==0;
}
for(int i=m;i<=n;i++) // print all prime numbers
{
if(prime[i]==1)
printf("%d\n",i);
}
t-=1;
}
}
#include<stdio.h>
int main()
{
int t,m,n;
scanf("%d",&t); // number of test cases
while(t>0)
{
scanf("%d%d",&m,&n);
int prime[n]; // for finding prime numbers
int listofprime[n]; // for storing only prime numbers
int pos=0;
for(int i=2;i<=n;i++) //declare all to 1
prime[i]=1;
prime[0]=0;
prime[1]=0;
for(int i=2;i*i<=n;i++) //simple sieve to find primes till sqrt(n)
{
if(prime[i]==1)
{
listofprime[pos]=i;
pos++;
for(int mult=2;i*mult<=n;mult++)
prime[i*mult]=0;
}
}
for(int i=0;listofprime[i]*listofprime[i]<=n;i++) //segmented sieve
{
int low=m/listofprime[i];
low*=listofprime[i];
for(int j=low+listofprime[i];j<=n;j+=listofprime[i])
prime[j]=0;
}
for(int i=m;i<=n;i++) // print all prime numbers
{
if(prime[i]==1)
printf("%d\n",i);
}
t-=1;
}
}