eval'[*%s..%s].repeated_permutation(%s){$.=$.*_1.inject(:gcd)%%(10**9+7)}'%gets.split p$.