object Main {
    def main(args:Array[String]) = {
        val sc = new java.util.Scanner(System.in)
        while(sc.hasNextInt) {
            val n = sc.nextInt
            println(primes(n).mkString(" "))
        }
   }
    def primes (n: Int): List[Int] =  {
        var i = n - 1
        while(!is_prime(i)) i -= 1
        var j = n + 1
        while(!is_prime(j)) j += 1
        List(i, j)
    }
    def is_prime (n: Int): Boolean = (2 to math.sqrt(n).toInt).toList.forall(x => n % x != 0)
}