require'openssl' M=10**9+7 E=Hash.new{|h,k|h[k]=[]} N,K=gets.split.map &:to_i IO.popen('factor '+gets){|_|_.map{|l|l.split[1..-1].map(&:to_i).group_by(&:+@).map{|k,v|E[k]<