candidates = []
m = 1
while true
    candidates << 7 * m + 1
    candidates << 7 * m + 6
    m += 1
    break if candidates.last > 300000
end
primes = [6]
candidates.each{|x|
    prime = true
    primes.each{|y|
        break if y > Math.sqrt(x)
        if x % y == 0
            prime = false
            break
        end
    }
    primes << x if prime
}
while true
    n = gets.to_i
    break if n == 1
    print "#{n}:"
    primes.each{|y| print " #{y}" if n % y == 0}
    puts
end

