def primelist( pmax )

	primes = Array.new( pmax + 1 )
	primes[ 0 ] = 0 
	primes[ 1 ] = 0 
	2.upto( pmax ){ |i|
		primes[ i ] = 1
	}

	max = Math.sqrt( pmax ).to_i

	prime = 0
	while true
		(prime+1).upto( pmax ){ |t|
			if primes[ t ] != 0
				prime = t 
				break
			end
		}
		break if prime > max 

		n = 2
		while prime * n <= pmax
			primes[ prime * n ] = 0
			n += 1
		end
	end

	plist = Array.new
	0.upto( pmax ).each{ |n|
		plist << n if primes[ n ] == 1
	}
	plist	
end


def main
	answers = Array.new
	list = primelist( 60000 )
	while line = $stdin.gets
		n = line.chomp.to_i

		i = 0
		while list[ i ] < n
			i += 1
		end
# list[i] == n or list[i] > n
# list[i] == n ?????¨??????list[ i -1 ] , list[ i + 1]
# list[i] > n?????¨??? list[i-1],list[i]
		a1 = list[ i - 1 ]		
		if list[ i ] == n
			a2 = list[ i + 1 ]
		else
			a2 = list[ i ]
		end
		answers << [ a1, a2]
	end

	answers.each{ |a|
		print "#{a[0]} #{a[1]}\n"
	}
end

main
