#!/usr/bin/env ruby

N = 60_000 # ??¢?´¢???????´???°?????????
elt = Array.new(N, 1) # ??¨????????????????????????????????????
primes = [] # ?´???°???????´???????


# ??¨????????????????????????
elt[0] = 0
elt[1] = 0

N.times do |i|
  next if elt[i].zero?
  primes << i
  k = i * 2
  while k < N
    elt[k] = 0
    k += i
  end
end
# ??\???????????????????????????
while line = gets
  n = line.chomp!.to_i
  (primes.length).times do |j|
    puts "#{primes[j-1]} #{primes[j+1]}" if n == primes[j]
  end
end