M = 300005
loop do
    n = gets.to_i
    break if n == 1
    print "#{n}:"
    p = Array.new(M,true)
    ret = Array.new
    i = 6
    while i <= n
        if p[i]
            print " #{i}" if n % i == 0
            j = i * 2
            while j <= n
                p[j] = false
                j += i
            end
        end
        i += 2
        if p[i]
            print " #{i}" if n % i == 0
            j = i * 2
            while j <= n
                p[j] = false
                j += i
            end
        end
        i += 5
    end
    puts
end