z=->x,y{r=1;y.times{r=x*r%M};r} M=10**9+7 E=Hash.new{|h,k|h[k]=[]} N,K=gets.split.map &:to_i IO.popen('factor '+gets){|io| io.each{|line| line.split[1..-1].map(&:to_i).group_by{|e|e}.each{|k,v|E[k]<