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