$prime = {}
def is_prime(n)
  unless $prime[n]
    if n < 2
      $prime[n] = false
    elsif n < 4
      $prime[n] = true
    elsif n % 2 == 0
      $prime[n] = false
    else
      i = 3
      flag = true
      while i <= Math.sqrt(n)
        if n % i == 0 then
          flag = false
          break
        end
        i += 2
      end
      $prime[n] = flag
    end
  end
  return $prime[n]
end

while n = gets
  m = n.to_i - 1
  m -= 1 if m % 2 == 0
  while not is_prime(m)
    m -= 2
  end
  print m
  m = n.to_i + 1
  m += 1 if m % 2 == 0
  while not is_prime(m)
    m += 2
  end
  puts " #{m}"
end