require 'prime'

ts, q = [], nil
Prime.take_while {|p| p <= 10000 }.each {|p|
  ts << p if p - 2 == q
  q = p
}
ts.reverse!
loop do
  n = gets.to_i
  break if n.zero?
  q = ts.bsearch {|p| p <= n }
  puts "#{q-2} #{q}"
end