#include <bits/stdc++.h>
using namespace std;
#define int              long long int
#define double           long double
#define print(a)         for(auto x : a) cout << x << " "; cout << endl


const int M = 1000000007;
const int N = 3e5+9;
const int INF = 2e9+1;
const int LINF = 2000000000000000001;

inline int power(int a, int b, int mod=M) {
    int x = 1;
    a %= mod;
    while (b) {
        if (b & 1) x = (x * a) % mod; 
        a = (a * a) % mod;
        b >>= 1;
    }
    return x;
}


//_ ***************************** START Below *******************************


int L;
int R;

vector<bool> isPrime;

void seive(){
	L = 1e12;
	R = 1e12+1e6;
	
	int rootR = sqrt(R);
	
	vector<bool> basePrime(rootR+1, 1);
	basePrime[0] = basePrime[1] = 0;
	
	vector<int> primes;
	
	
	for(int i=2; i<=rootR; i++){
		if(basePrime[i] == 0) continue;
		
		primes.push_back(i);
		for(int j=i*i; j<=rootR; j+=i){
			basePrime[j] = 0;
		}
	}
	
	
	isPrime.assign(R-L+1, 1);
	
	for(auto& p : primes){
		
		int firstMultiple = ( (L+p-1)/p ) * p;
		
		int start = max(firstMultiple , p*p);
		
		for(int j = start; j<=R; j+=p){
			isPrime[j - L] = 0;
		}
		
	}
	
	if(L == 0) {
        if(R >= 0) isPrime[0] = false;
        if(R >= 1) isPrime[1] = false;
    }
	if(L == 1) isPrime[0] = false;
	
}

void consistency(int l, int r){
	
	if(l < L || r > R){
        cout << "Query outside precomputed range\n";
        return;
    }
    
	for(int i=l; i<=r ; i++){
		if(isPrime[i-L]) cout << i << " ";
	}cout << endl;

}















void practice(int l, int r){


}





void solve() {
	static int _ = (seive(), 0);
	
    int l, r;
    cin>> l >> r;
    
    consistency(l, r);


}





int32_t main() {
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

    int t = 1;
    cin >> t;
    while (t--) {
        solve();
    }

    return 0;
}