require 'prime'

class Array
  def upper_bound(num)
    a = 0
    b = size

    while a < b
      c = ( a + b ) / 2

      if num < at(c)
        b = c
      else
        a = c+1
      end
    end

    at(b)
  end

  def lower_bound(num)
    a = 0
    b = size

    while a < b
      c = ( a + b ) / 2

      if num <= at(c)
        b = c
      else
        a = c + 1
      end
    end

    at(b-1)
  end
end

class Solver
  def initialize
    prime_list = Prime::instance.take(25000)

    loop do
      num = gets

      break unless num

      num = num.chomp.to_i

      puts [ prime_list.lower_bound(num), prime_list.upper_bound(num) ].join(' ')
    end
  end
end

Solver.new