def main
  prime = Array.new(50100,true)
  for i in 2..prime.length ** 0.5
    if prime[i]
      for j in 2..50100 / i
        prime[i * j] = false
      end
    end
  end
  prime[0], prime[1] = false, false
  while (n = gets.to_i)
    m = n - 1
    until prime[m]
      m -= 1
    end
    print m.to_s + " "
    m = n + 1
    until prime[m]
      m += 1
    end
    print m.to_s + "\n"
  end
end
main