#include <iostream>
using namespace std;

int main() {
	// your code goes here
	int numberOfLines;
	int m; //beginning of prime numbers
	int n; //ending of prime numbers
	int x;
	int *arrayPtr;
	//Read in the numbers 
	std::cin >> numberOfLines;
	
	//Create an array with numberOfLines
	for (int i = 0; i < numberOfLines; i++){
		std::cin >> m >> n;
		arrayPtr = new int[(n-m)+1];
		int counter = 0;
	
		//Check condition m >= 1 && n >=1
		if (m >= 1 && n >= 1)
			
			//check second condition
			if ( m <= 1000000000 && n <= 1000000000)
				//check third condition
				if (n-m<= 100000){
					for (int x = m; x <= n; x++){
						if (x == 1){
						}
						else if (x == 2 || x == 3 || x == 5 || x == 7 || x == 11){
							arrayPtr[counter] = x;
							counter++;
						}
						else if (x%2 == 0 || x%3 == 0 || x%5 == 0 || x%7 == 0 || x%11 == 0)
							{}
						else
						{
							arrayPtr[counter] = x;		
							counter++;
						}
					}
				}
				
	for (int i = 0; i < counter; i++)
		std::cout << arrayPtr[i] << "\n";
	std::cout << "\n";
	delete arrayPtr;
	}	
	
	return 0;
}