from subprocess import*

x=int(eval(input()))

while len(Popen(['factor',str(x)],stdout=PIPE).communicate()[0].split())>2:x+=1

print(x)
x=int(eval(input()))

while any(x%i<1for i in range(2,x)):x+=1

print(x)
from subprocess import *

x = int(eval(input()))
while len(Popen(["factor", str(x)], stdout=PIPE).communicate()[0].split()) > 2:
    x += 1
print(x)

x = int(eval(input()))
while any(x % i < 1 for i in range(2, x)):
    x += 1
print(x)

-from subprocess import * - -while len(Popen(["factor", str(x)], stdout=PIPE).communicate()[0].split()) > 2: +while any(x % i < 1 for i in range(2, x)):