
n = int(input())
l = []
l1 = []
for i in range(n):
    l1 = list(map(int , input().split()))
    num1 = l1[0]
    num2 = l1[1]
    if num1 == 1:
        num1 = num1 + 1
    for i in range(num1, num2+1):
        for j in range(2, i):
            if i % j == 0:
                break
        else:
            l.append(i)
print(*l , sep = "\n")

f29f8f1309e82f2d4cbfc839bb0f8fd279ae27d7
<mask token>

<mask token>
for i in range(n):
    l1 = list(map(int, input().split()))
    num1 = l1[0]
    num2 = l1[1]
    if num1 == 1:
        num1 = num1 + 1
    for i in range(num1, num2 + 1):
        for j in range(2, i):
            if i % j == 0:
                break
        else:
            l.append(i)
print(*l, sep='\n')

n = int(input())
l = []
l1 = []
for i in range(n):
    l1 = list(map(int, input().split()))
    num1 = l1[0]
    num2 = l1[1]
    if num1 == 1:
        num1 = num1 + 1
    for i in range(num1, num2 + 1):
        for j in range(2, i):
            if i % j == 0:
                break
        else:
            l.append(i)
print(*l, sep='\n')


n = int(input())
l = []
l1 = []
for i in range(n):
    l1 = list(map(int , input().split()))
    num1 = l1[0]
    num2 = l1[1]
    if num1 == 1:
        num1 = num1 + 1
    for i in range(num1, num2+1):
        for j in range(2, i):
            if i % j == 0:
                break
        else:
            l.append(i)
print(*l , sep = "\n")
