prime = Array.new(10000,true)

prime[0] = false
prime[1] = false
for i in 2..9999 do
    if prime[i]
        k = 2
        s = i * k
        while s < 10000
         prime[s] = false
         k += 1
         s = i * k
        end
       i += 1
    else
        i += 1
    end
end

primenumber = prime.each_with_index.select{|e, i| e == true}.map{|e| e[1]}

ans_prime_list = []
primenumber.each do |t|
    if primenumber.include?(t+2)
        ans_prime_list << t + 2
    i += 1
    end
end
primenumber2 = ans_prime_list.reverse
n = gets.to_i
until n == 0
    ans = primenumber2.select{|k| k <= n }
    asas = ans[0] - 2
    puts "#{asas} #{ans[0]}"
    n = gets.to_i
end
