import java.util.Scanner;
class ACM_Primes {
public static void main(String[] args) {
Scanner ler = new Scanner (System.in);
int n = ler.nextInt();
for (int a = 1; a <= n; a++) {
int x = ler.nextInt();
int y = ler.nextInt();
for (int i = x ; i <= y ; i++) {
if(i < 10) {
byte div = 0;
for (int j = 1 ; j <= 9 ; j++) {
if(i % j == 0)
div++;
if(div > 2)
break;
}
if(div == 2)
System.out.println(i);
}
else {
boolean prime = true;
for (int j = 2 ; j <= 9 ; j++) {
if(i % j == 0)
prime = false;
if(!prime)
break;
}
if(prime)
System.out.println(i);
}
}
System.out.println();
}
}
}