#include <iostream>
#include <math.h>
using namespace std;
int main()
{
short ilebadan;
cin >> ilebadan;
short *badanie = new short[ilebadan];
int *odilu = new int[ilebadan];
int *ile = new int[ilebadan];
for (int x = 0; x < ilebadan; x += 1)
{
cin >> odilu[x] >> ile[x];
}
for (int x = 0; x < ilebadan; x += 1)
{
bool *booltab = new bool[ile[x]];
for (int i = 0; i < ile[x]; i += 1)
{
booltab[i] = true;
}
for (int i = 2; i <= (sqrt(ile[x])); i += 1)
{
if (booltab[i - 2] == true)
{
int j = 0;
for (int it = 0; j <= (ile[x] + 1); it += 1)
{
j = ((i*i) + (it*i));
booltab[j - 2] = false;
}
}
}
for (int i = 0; i < ile[x]; i += 1)
{
if (booltab[i] == true && (i+2) >= odilu[x] && (i+2) <= ile[x]) cout << (i + 2) << endl;
}
cout << endl;
}
delete[] badanie;
delete[] odilu;
delete[] ile;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgojaW5jbHVkZSA8bWF0aC5oPgp1c2luZyBuYW1lc3BhY2Ugc3RkOwppbnQgbWFpbigpCnsKCXNob3J0IGlsZWJhZGFuOwoJY2luID4+IGlsZWJhZGFuOwoKCXNob3J0ICpiYWRhbmllID0gbmV3IHNob3J0W2lsZWJhZGFuXTsKCQoJaW50ICpvZGlsdSA9IG5ldyBpbnRbaWxlYmFkYW5dOwoJaW50ICppbGUgPSBuZXcgaW50W2lsZWJhZGFuXTsKCglmb3IgKGludCB4ID0gMDsgeCA8IGlsZWJhZGFuOyB4ICs9IDEpCgl7CgkJY2luID4+IG9kaWx1W3hdID4+IGlsZVt4XTsKCX0KCglmb3IgKGludCB4ID0gMDsgeCA8IGlsZWJhZGFuOyB4ICs9IDEpCgl7CgkJYm9vbCAqYm9vbHRhYiA9IG5ldyBib29sW2lsZVt4XV07CgoJCWZvciAoaW50IGkgPSAwOyBpIDwgaWxlW3hdOyBpICs9IDEpCgkJewoJCQlib29sdGFiW2ldID0gdHJ1ZTsKCQl9CgoKCQlmb3IgKGludCBpID0gMjsg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