X = int(eval(input()))

result = False



while result == False:

  result = True

  for i in range(2,-(-X//2)+1):

    if X % i == 0:

      result = False

      break

    else:

      result = True

  if not result:

    X += 1

print(X)

X = int(eval(input()))-1

result = False



while not result:

  result = True

  X += 1

  for i in range(2,X//2+1):

    if X % i == 0:

      result = False

      break

print(X)
X = int(eval(input()))
result = False
while result == False:
    result = True
    for i in range(2, -(-X // 2) + 1):
        if X % i == 0:
            result = False
            break
        else:
            result = True
    if not result:
        X += 1
print(X)

X = int(eval(input())) - 1
result = False
while not result:
    result = True
    X += 1
    for i in range(2, X // 2 + 1):
        if X % i == 0:
            result = False
            break
print(X)

-X = int(eval(input())) +X = int(eval(input())) - 1 -while result == False: +while not result: -    for i in range(2, -(-X // 2) + 1): +    X += 1 +    for i in range(2, X // 2 + 1): -        else: -            result = True -    if not result: -        X += 1