M = 300005
ms = Array.new(M,false)
i = 0
while i <= M
    ms[i+1] = ms[i+6] = true
    i += 7
end

p = Array.new(M,true)
p[0] = p[1] = false
2.upto(M) do |i|
    next if !ms[i]
    j = i * 2
    while j <= M
        p[j] = false
        j += i
    end
end


loop do
    n = gets.to_i
    break if n == 1
    print "#{n}:"
    6.upto(n) do |i|
        print " #{i}" if ms[i] && p[i] && n % i == 0
    end
    puts
end