import math

def isPrime(num): # Check if a given number is a prime
                                 # Using divison trial method
    square = math.sqrt(num)      # The square root is the ceiling of divisible numbers
    divisor = 2                  # Increments by one until it hits the square root
    if num == 1: return False
    while divisor <= square:
        if num % divisor == 0: # If theres no remainer than the number is not a prime
            return False
        else:
            divisor += 1         # Increment until reaching sqrt
    return True
## ----------------------------------------------------------------------- ##
raw_prime_list = list()
prime_list = list()
 
input_prime = int(raw_input())

while len(raw_prime_list) < input_prime:
    input = raw_input()
    raw_prime_list.append(input)
    
for entry in raw_prime_list:
    x, y = entry.split(' ')
    x = int(x)
    y = int(y)
    
    while x <= y:
        if isPrime(x):
            print(x)
        x += 1
    print('\n')
