a=[]
b=[]
a[0]=0
a[1]=0
for i in 2...50100
  a[i]=1
end
for i in 2...50100
  if a[i]==1 then
    j=i*2
    while j < 50100 do
    a[j]=0
    j=j+i
    end
  end
end

while inp=gets.to_i do
  i=inp-1
  while 1 do
    if a[i]==1 then
      print i," "
      break
    end
    i=i-1
  end
i=inp+1
  while 1 do
    if a[i]==1 then
    print i,"\n"
    break
    end
  i=i+1
  end
end