def isprime(num):
for n in range(2,int(num**1/2)+1):
if num%n==0:
return False
return True
t=int(input())
for i in range(t):
a=int(input())
b=int(input())
while a<b+1:
if isprime(a):
print(a , end=" ")
a=a+1
else:
a=a+1
print("")