N=50021
prime = [false,false] + [true]*(N-1)
(2..(Math.sqrt(N).to_i+1)).each do |i|
  next unless prime[i]
  (i*i).step(N, i).each do |j|
    prime[j] = false
  end
end

while gets do
  n = $_.to_i
  min = (2..(n-1)).to_a.reverse.find { |i| prime[i] } || 1
  max = ((n+1)..N).find { |i| prime[i] } || 1
  puts sprintf("%d %d", min, max)
end