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