#include<bits/stdc++.h>
using namespace std;
void kt(int l, int r)
{
bool prime[r - l + 1];
memset(prime,true,sizeof(prime));
for (long long i = 2; i * i <= r; ++i)
{
for (long long j = max(i * i, (l + (i - 1)) / i * i); j <= r; j += i)
{
prime[j - l] = false;
}
}
for (long long i = max(l, 2); i <= r; ++i)
{
if (prime[i - l])
{
cout<<i<<endl;
}
}
}
int main()
{
long long a,b,t;
cin>>t;
for (int i=1;i<=t;i++)
{
cin>>a>>b;
kt(a,b);
cout<<endl;
}
return 0;
}
I2luY2x1ZGU8Yml0cy9zdGRjKysuaD4KCnVzaW5nIG5hbWVzcGFjZSBzdGQ7CnZvaWQga3QoaW50IGwsIGludCByKQp7CiAgICBib29sIHByaW1lW3IgLSBsICsgMV07CiAgICBtZW1zZXQocHJpbWUsdHJ1ZSxzaXplb2YocHJpbWUpKTsKICAgIGZvciAobG9uZyBsb25nIGkgPSAyOyBpICogaSA8PSByOyArK2kpCiAgICAgICAgewogICAgICAgIGZvciAobG9uZyBsb25nIGogPSBtYXgoaSAqIGksIChsICsgKGkgLSAxKSkgLyBpICAqIGkpOyBqIDw9IHI7IGogKz0gaSkKICAgICAgICB7CiAgICAgICAgICAgIHByaW1lW2ogLSBsXSA9IGZhbHNlOwogICAgICAgIH0KICAgIH0KICAgIGZvciAobG9uZyBsb25nIGkgPSBtYXgobCwgMik7IGkgPD0gcjsgKytpKQogICAgewogICAgICAgIGlmIChwcmltZVtpIC0gbF0pCiAgICAgICAgewogICAgICAgICAgICBjb3V0PDxpPDxlbmRsOwogICAgICAgIH0KICAgIH0KfQppbnQgbWFpbigpCnsKICAgIGxvbmcgbG9uZyBhLGIsdDsKICAgIGNpbj4+dDsKICAgIGZvciAoaW50IGk9MTtpPD10O2krKykKICAgIHsKICAgICAgICBjaW4+PmE+PmI7CiAgICAgICAga3QoYSxiKTsKICAgICAgICBjb3V0PDxlbmRsOwogICAgfQogICAgcmV0dXJuIDA7Cn0K