require 'prime'

while n = gets do
	n = n.chomp.strip.to_i
	m, l = 0
	(n - 1).downto(3) {|i|
		if i.prime?
			m = i
			break
		end
	}
	(n + 1).upto(50000) {|i|
		if i.prime?
			l = i
			break
		end
	}
	puts "#{m} #{l}"
end