import scala.io.Source.stdin

object Main {
  def sieve(n:Int) = {
    val primes = Array.tabulate(n+1) { _ % 2 }
    primes(1) = 0
    primes(2) = 1

    for( i <- 3 to Math.sqrt(n).toInt by 2 )
      if(primes(i) == 1)
        (i*i to n by i*2).foreach { primes(_) = 0 }
    primes
  }

  def main(args:Array[String]) = {
    val p = sieve(51000)
    for(i <- stdin.getLines){
      val n = i.toInt
      val l = (n+1 to 51000).find(p(_)==1).get
      val s = (n-1 to 1 by -1).find(p(_)==1).get
      println(s + " " + l)
    }
  }
}