require 'prime' def pow(x,y) z=1 while y!=0 z=z*x%M if y&1!=0 x=x*x%M y>>=1 end z end M=10**9+7 N,K,*A=$<.read.split.map(&:to_i) E=Hash.new{|h,k|h[k]=[]} A.each{|e|e.prime_division.each{|n,p|E[n]<