X = int(eval(input()))



n = 2 * X

is_prime = [False] * 2 + [True] * (n - 1)



for i in range(2, int(n ** 0.5) + 1): # 素数候補

    if not is_prime[i]: continue

    for j in range(2 * i, n + 1, i):

        is_prime[j] = False



for i in range(X, n):

    if is_prime[i]:

        print(i)

        break
X = int(eval(input()))



p = X

while True:

    for j in range(2, int(p ** 0.5) + 1):

        if p % j == 0: break

    else:

        break

    p += 1



print(p)
X = int(eval(input()))
n = 2 * X
is_prime = [False] * 2 + [True] * (n - 1)
for i in range(2, int(n**0.5) + 1):  # 素数候補
    if not is_prime[i]:
        continue
    for j in range(2 * i, n + 1, i):
        is_prime[j] = False
for i in range(X, n):
    if is_prime[i]:
        print(i)
        break

X = int(eval(input()))
p = X
while True:
    for j in range(2, int(p**0.5) + 1):
        if p % j == 0:
            break
    else:
        break
    p += 1
print(p)

-n = 2 * X -is_prime = [False] * 2 + [True] * (n - 1) -for i in range(2, int(n**0.5) + 1):  # 素数候補 -    if not is_prime[i]: -        continue -    for j in range(2 * i, n + 1, i): -        is_prime[j] = False -for i in range(X, n): -    if is_prime[i]: -        print(i) +p = X +while True: +    for j in range(2, int(p**0.5) + 1): +        if p % j == 0: +            break +    else: +    p += 1 +print(p)