#include<bits/stdc++.h>
using namespace std;
int ans[2000005];
bool status[20000005];
bool vis[20000005];
int main(){
int t;
scanf("%d",&t);
while(t--){
memset(status,0,sizeof status);
memset(vis,0,sizeof vis);
long long l,r;
scanf("%lld %lld",&l,&r);
//cout<<l<<endl;
int pm=0;
//long long p=ceil((int)sqrt(r));
for(long long i=2;i*i<=r;i++){
if(!status[i]){
ans[pm]=i;
pm++;
for(long long k=2*i;k<=10000000;k+=i)
status[k]=1;
}
}
for(int k=0;k<pm;k++){
long long st=ceil(l/ans[k]);
if(st==0) st+=2;
if(st==1) st++;
for(long long j=st*ans[k];j<=r;j+=ans[k])
{
vis[j-l]=1;
}
}
for(long long i=l;i<=r;i++){
if(!vis[i-l])
printf("%lld\n",i);
}
}
return 0;
}
I2luY2x1ZGU8Yml0cy9zdGRjKysuaD4KCnVzaW5nIG5hbWVzcGFjZSBzdGQ7CmludCBhbnNbMjAwMDAwNV07CmJvb2wgc3RhdHVzWzIwMDAwMDA1XTsKYm9vbCB2aXNbMjAwMDAwMDVdOwoKaW50IG1haW4oKXsKICAgIGludCB0OwogICAgc2NhbmYoIiVkIiwmdCk7CiAgICB3aGlsZSh0LS0pewogICAgICAgICAgICBtZW1zZXQoc3RhdHVzLDAsc2l6ZW9mIHN0YXR1cyk7CiAgICAgICAgICAgIG1lbXNldCh2aXMsMCxzaXplb2YgdmlzKTsKICAgICAgICBsb25nIGxvbmcgbCxyOwogICAgICAgIHNjYW5mKCIlbGxkICVsbGQiLCZsLCZyKTsKICAgICAgICAvL2NvdXQ8PGw8PGVuZGw7CgogICAgICAgaW50IHBtPTA7CiAgICAgICAgLy9sb25nIGxvbmcgcD1jZWlsKChpbnQpc3FydChyKSk7CiAgICAgICAgZm9yKGxvbmcgbG9uZyBpPTI7aSppPD1yO2krKyl7CiAgICAgICAgICAgIGlmKCFzdGF0dXNbaV0pewogICAgICAgICAgICAgICAgYW5zW3BtXT1pOwogICAgICAgICAgICAgICAgcG0rKzsKICAgICAgICAgICAgICAgIGZvcihsb25nIGxvbmcgaz0yKmk7azw9MTAwMDAwMDA7ays9aSkKICAgICAgICAgICAgICAgICAgICBzdGF0dXNba109MTsKICAgICAgICAgICAgfQogICAgICAgIH0KCiAgICAgICAgZm9yKGludCBrPTA7azxwbTtrKyspewogICAgICAgICAgICBsb25nIGxvbmcgc3Q9Y2VpbChsL2Fuc1trXSk7CiAgICAgICAgICAgIGlmKHN0PT0wKSBzdCs9MjsKICAgICAgICAgICAgaWYoc3Q9PTEpIHN0Kys7CiAgICAgICAgICAgIGZvcihsb25nIGxvbmcgaj1zdCphbnNba107ajw9cjtqKz1hbnNba10pCiAgICAgICAgICAgICAgICB7CiAgICAgICAgICAgICAgICAgICAgdmlzW2otbF09MTsKICAgICAgICAgICAgICAgIH0KICAgICAgICB9CgogICAgICAgZm9yKGxvbmcgbG9uZyBpPWw7aTw9cjtpKyspewogICAgICAgICAgICBpZighdmlzW2ktbF0pCiAgICAgICAgICAgICAgICBwcmludGYoIiVsbGRcbiIsaSk7CiAgICAgICAgfQoKICAgIH0KICByZXR1cm4gMDsKfQo=