N = 10100
ps = []

isp = Array.new(N,true)
(2..N).step 2 do |i|
  isp[i] = false
end
(3..N).step(2) do |i|
  next unless isp[i]
  ps << i
  ((i+i)..N).step(i) do |j|
    isp[j] = false
  end
end

while (n=gets.to_i)!=0
  ans = -1
  (ps.length-1).times do |i|
    if ps[i+1] > n
      break
    end
    if ps[i]+2 == ps[i+1]
      ans = i
    end
  end
  puts ps[ans,2].join(' ')
end