#include <iostream>
#include <cmath>

using namespace std;
bool isPrime(int n);

int main()
{

    int num;
	cin >> num;
	int x1, x2;

	while(num)
	{
		cin >> x1 >> x2;
		while(x1 <= x2)
		{
			if(isPrime(x1))
				cout << x1 << endl;
			x1++;
		}
		num--;
	}
	return 0;
}


bool isPrime(int n)
{
	if(n == 1 || n == 0)
		return false;

	if(n % 2 == 0 && n != 2)
		return false;

	int sq = sqrt(n);

	for(int i = 3;i <= sq; )
	{
		if(n % i == 0)
		{
			return false;
		}
		i += 2;
	}

	return true;
}