require 'prime'

twin_prime = Prime.each(10000).each_cons(2).select{ |p, q| q - p == 2}

loop do
	n = gets.to_i
	break if n.zero?
	ans = twin_prime.select{ |twin| twin.last <= n }.last
	puts ans.join(' ')
end