a,b=gets.split(" ").map(&:to_i)
copr=[]
gcd=a.gcd(b)
i=2
while i<=gcd
  if a%i==0 and b%i==0
  copr << i
  end
  i+=1
end
puts copr.join(" ")
n=1
while copr!=[]
  copr.reject!{|e| e%copr[0]==0}
  n+=1
  puts copr.join(" ")
end
puts n