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