N=50021
p=Array.new(N+1,true);
p[0]=p[1]=false;
for i in 2..Math.sqrt(N).to_i
  next if !p[i]
  j=i*2
  while j<=N
    p[j]=false;
    j+=i
  end
end
n=gets.to_i
x=n-1
until x<2
  break if p[x]
  x-=1
end
for y in n+1..50021 do
  break if p[y]
end
puts [x,y].join(' ')