#include <iostream>
#include
using namespace std;
int main(){
int t;
cin>>t;
vector v (100001,1);
//vector v1;
v[0]=0;v[1]=0;
for(int i=0;i<=100000;i++){
if(v[i]){
//v1.push_back(i);
//cout<<i<<endl;
for(int j=2i;j<=100000;j+=i){
v[j]=0;
}
}
}
for(int i1=0;i1<t;i1++){
int a,b;
cin>>a>>b;
if(b<100000){
int i=a;
for(;i<=b;i++){
if(v[i])
cout<<i<<endl;
}
}
else{
if(a<100000){
for(int i=a;i<=100000;i++){
if(v[i])
cout<<i<<endl;
}
for(int i=100000;i<=b;i++){
int w=0;
for(int j=2;jj<i;j++){
if(v[j]){
if(i%j==0){
w++;
break;
}
}
}
if(w==0)
cout<<i<<endl;
}
}
else{
for(int i=a;i<=b;i++){
int w=0;
for(int j=2;j*j<i;j++){
if(v[j]==1){
//cout<<j<<endl;
if(i%j==0){
w++;
break;
}
}
}
if(w==0)
cout<<i<<endl;
}
}
}
if(i1!=t-1)
cout<<endl;
}}