#include<iostream>
#include<math.h>
using namespace std;
int main() {
int a,i,j,k,d,u;
float g;
cin>>d;
for(k=0;k<d;k++) {
cin>>u;
cin>>a;
g=a;
bool m[a];
for(i=2;i<=a;i++) {
m[i]=true;
}
float z;int q;
z=sqrt(g);
for(i=2;i<=z;i++) {
if(m[i]==true) {
for(j=0;;j++) {
q=(i*i)+(j*i);
if(q<=a)
m[q]=false;
else
break;
}
}
}
for(i=2;i<=a;i++) {
if((m[i]==true)&&(i>=u))
cout<<i<<"\n";
}
cout<<"\n";
}
return 0;
}
I2luY2x1ZGU8aW9zdHJlYW0+CgojaW5jbHVkZTxtYXRoLmg+CnVzaW5nIG5hbWVzcGFjZSBzdGQ7CmludCBtYWluKCkgewogICAgaW50IGEsaSxqLGssZCx1OwoJZmxvYXQgZzsKCgljaW4+PmQ7Cglmb3Ioaz0wO2s8ZDtrKyspIHsKCQljaW4+PnU7CgkJY2luPj5hOwogICAgCgkJZz1hOwoJCWJvb2wgbVthXTsKCQlmb3IoaT0yO2k8PWE7aSsrKSB7CgkJCW1baV09dHJ1ZTsgCgkJfQoJCWZsb2F0IHo7aW50IHE7CgkJej1zcXJ0KGcpOwoKCQlmb3IoaT0yO2k8PXo7aSsrKSB7CgkJCWlmKG1baV09PXRydWUpIHsKCQkJCWZvcihqPTA7O2orKykgewoJCQkJCXE9KGkqaSkrKGoqaSk7CgkJCQkJaWYocTw9YSkKCQkJCQltW3FdPWZhbHNlOwoJCQkJCWVsc2UKCQkJCQlicmVhazsKCQkJCX0KCQkJfSAgICAKCQl9CgoJCWZvcihpPTI7aTw9YTtpKyspIHsKCQkJaWYoKG1baV09PXRydWUpJiYoaT49dSkpICAgIAoJCQljb3V0PDxpPDwiXG4iOwoJCX0gICAgICAgIAoJCWNvdXQ8PCJcbiI7Cgl9ICAgIAoJcmV0dXJuIDA7Cn0K