#include<bits/stdc++.h>
typedef long long int ll;
#define pb                  push_back
#define arr                 vector<ll>
#define mem(x)              memset(x,0,sizeof(x))
#define vp(x)               vector<pair<ll,ll>>x
#define matrix              vector<vector<ll> >
using namespace std;
vector<ll> primeseive(ll x){
   vector<ll>w;
   ll d[x+1];
   memset(d,1,sizeof(d));
   d[0]=0;
   d[1]=0;
   for(int i=4;i<=x;i+=2)
       d[i]=0;
   for(ll i=3;i<=x;i+=2){
       if(d[i]){
           for(ll j=i*i;j<=x;j+=2*i){
               d[j]=0;
           }
       }
   }
   for(ll i=0;i<=x;i++)
       if(d[i]){
           w.push_back(i);
       }
   return w;
}
void solve(){
    ll a,b;
    cin>>a>>b;
    arr w=primeseive(sqrt(b));
    ll array[100000];
    mem(array);
    for (ll index=0;index<b-a;index++){
        for (ll i=0;i<w.size();i++){
            if ((index+a)%w[i]==0)
                    array[index]=1;
        }
    }
    for (ll i=0;i<b-a;i++){
        if (array[i]==0)
            cout<<i+a<<endl;
    }
    cout<<endl;
}
int main(){
    ll t;cin>>t;
    while (t--)
    solve();
    return 0;
}
