Given two numbers L and R (inclusive) find the product of primes within this range. Print the product modulo 10^{9}+7. If there are no primes in that range you must print 1.
Example 1:
Input: L = 1, R = 10
Output: 210
Explaination: The prime numbers are 
2, 3, 5 and 7.
Example 2:
Input: L = 1, R = 20
Output: 9699690
Explaination: The primes are 2, 3, 
5, 7, 11, 13, 17 and 19.
Your Task:
You do not need to read input or print anything. Your task is to complete the function primeProduct() which takes L and R and returns the product of the primes within the range. If there are no primes in that range then return 1.
Expected Time Complexity: O((R-L)*(logR))
Expected Auxiliary Space: O(sqrt(R))
Constraints:
1 ≤ L ≤ R ≤ 10^{9}
0 ≤ L - R ≤ 10^{6}

Difficulty: MEDIUM
Tags: Number theory
Expected Time Complexity: O((R-L)*(logR))
Expected Auxiliary Space: O(sqrt(R))

Starter code:
#User function Template for python3



class Solution:

    def primeProduct(self, L, R):

        # code here

Solutions:
class Solution:

	def primeProduct(self, L, R):

		def fun(n):
			primes = [1] * (n + 1)
			primes[0] = 0
			primes[1] = 0
			for i in range(2, n + 1):
				if primes[i] == 1:
					for j in range(i + i, n + 1, i):
						primes[j] = 0
			op = []
			for i in range(2, n + 1):
				if primes[i] == 1:
					op.append(i)
			return op
		mul = fun(int(R ** 0.5))
		dum = [1] * (R - L + 1)
		for i in mul:
			fm = L // i * i
			if fm < L:
				fm += i
			if fm <= 3:
				fm += fm
				dum[0] = 0
			for j in range(fm, R + 1, i):
				dum[j - L] = 0
		op = []
		pro = 1
		for i in range(L, R + 1):
			if dum[i - L] == 1:
				pro *= i
				op.append(i)
		return pro % (10 ** 9 + 7)


import math

def is_prime(n):
	if n == 1:
		return False
	if n == 2 or n == 3:
		return True
	if n % 2 == 0:
		return 0
	for i in range(3, int(math.sqrt(n)) + 1, 2):
		if n % i == 0:
			return False
	return True

class Solution:

	def primeProduct(self, L, R):
		p = 1
		for i in range(L, R + 1):
			if is_prime(i):
				p *= i
		return p % (10 ** 9 + 7)


import math

class Solution:

	def isprime(self, n):
		if n == 1:
			return False
		if n == 2 or n == 3:
			return True
		if n % 2 == 0 or n % 3 == 0:
			return False
		for i in range(5, int(n ** 0.5) + 1, 6):
			if n % i == 0 or n % (i + 2) == 0:
				return False
		return True

	def primeProduct(self, L, R):
		prime = 1
		for n in range(L, R + 1):
			if self.isprime(n):
				prime *= n
		return prime % 1000000007


class Solution:

	def primeProduct(self, L, R):
		if R < 2:
			return 1
		primes = [True] * (R - L + 1)
		if L == 1:
			primes[0] = False
		for i in range(2, int(R ** 0.5) + 1):
			for j in range(max(i * i, (L + i - 1) // i * i), R + 1, i):
				primes[j - L] = False
		product = 1
		for i in range(L, R + 1):
			if primes[i - L]:
				product = product * i % (10 ** 9 + 7)
		return product


class Solution:

	def primeProduct(self, L, R):
		p = 1
		for i in range(L, R + 1):
			if isprime(i):
				p *= i
		return p % 1000000007

def isprime(num):
	if num == 1:
		return False
	elif num == 2 or num == 3:
		return True
	elif num % 2 == 0 or num % 3 == 0:
		return False
	else:
		for i in range(5, int(num ** 0.5) + 1, 6):
			if num % i == 0 or num % (i + 2) == 0:
				return False
		else:
			return True


import math

class Solution:

	def primeProduct(self, L, R):

		def isprime(n):
			if n <= 1:
				return False
			if n == 2:
				return True
			if n % 2 == 0:
				return False
			for i in range(3, int(math.sqrt(n)) + 1, 2):
				if n % i == 0:
					return False
			return True
		prod = 1
		if L <= 2:
			prod = 2
		if L % 2 == 0:
			L += 1
		for num in range(L, R + 1, 2):
			if isprime(num):
				prod *= num
		return prod % 1000000007


class Solution:

	def primeProduct(self, L, R):

		def isPrime(n):
			k = int(n ** 0.5) + 1
			for i in range(3, k, 2):
				if not n % i:
					return False
			return True
		p = 1
		if L < 3:
			L == 3
			if R >= 2:
				p = 2
		if not L % 2:
			L += 1
		for i in range(L, R + 1, 2):
			if isPrime(i):
				p *= i
		return p % 1000000007


class Solution:

	def primeProduct(self, L, R):
		product = 1
		for i in range(L, R + 1):
			if i % 2:
				for j in range(3, int(i ** 0.5) + 1, 2):
					if i % j == 0:
						break
				else:
					product *= i
			if i == 2:
				product *= 2
		return product % 1000000007


import math

class Solution:

	def sieve(self, N):
		l = [0] * (N + 1)
		k = 2
		while k * k <= N:
			if l[k] == 0:
				j = k * k
				for i in range(j, N + 1, k):
					l[i] = 1
			k += 1
		b = []
		for i in range(2, N + 1):
			if l[i] == 0:
				b.append(i)
		return b

	def primeProduct(self, L, R):
		if L < 2:
			L = 2
		flag = [True] * (R - L + 1)
		k = int(R ** 0.5)
		l = self.sieve(k)
		for i in l:
			d = math.ceil(L / i)
			if d == 1:
				d = 2
			while i * d - L < R - L + 1:
				flag[i * d - L] = False
				d += 1
		p = 1
		for i in range(R - L + 1):
			if flag[i]:
				p = p * (i + L)
				p = p % 1000000007
		return p


import math
import numpy

class Solution:

	def countPrime(self, n):
		primes = [0, 0] + [1] * (n + 1)
		primeNums = []
		for i in range(2, n + 1):
			if primes[i] == 1:
				for j in range(2 * i, n + 1, i):
					primes[j] = 0
		for i in range(2, n + 1):
			if primes[i] == 1:
				primeNums.append(i)
		return primeNums

	def primeProduct(self, L, R):
		m = 10 ** 9 + 7
		limit = int(math.floor(math.sqrt(R)) + 1)
		primes = self.countPrime(limit)
		primeNums = []
		low = max(L, limit + 1)
		high = low + limit - 1
		while low <= R:
			if high > R:
				high = R
			isPrime = [1] * (limit + 1)
			for i in range(len(primes)):
				sm = low // primes[i] * primes[i]
				if sm < low:
					sm += primes[i]
				for j in range(sm, high + 1, primes[i]):
					isPrime[j - low] = 0
			for i in range(low, high + 1):
				if isPrime[i - low] == 1:
					primeNums.append(i)
			low = high + 1
			high += limit
		primeNums = primes + primeNums
		final = []
		product = 1
		for i in range(len(primeNums)):
			if L <= primeNums[i] <= R:
				final.append(primeNums[i])
				product = product % m * (primeNums[i] % m) % m
		return product


from math import sqrt

class Solution:

	def prime(self, n):
		if n == 1 or n == 0:
			return False
		if n == 2 or n == 3:
			return True
		if n % 2 == 0 or n % 3 == 0:
			return False
		for i in range(5, int(sqrt(n)) + 1, 6):
			if n % i == 0 or n % (i + 2) == 0:
				return False
		return True

	def primeProduct(self, L, R):
		d = 1
		for i in range(L, R + 1):
			if self.prime(i):
				d = d * i
				d = d % (10 ** 9 + 7)
		return d % (10 ** 9 + 7)


import math

class Solution:

	def primeProduct(self, L, R):
		m = 1
		for i in range(L, R + 1):
			if self.isprime(i) == 1:
				m *= i
		return m % (10 ** 9 + 7)

	def isprime(self, i):
		if i == 2 or i == 3:
			return 1
		elif i <= 1 or i % 2 == 0 or i % 3 == 0:
			return 0
		for j in range(5, int(math.sqrt(i)) + 1, 6):
			if i % j == 0 or i % (j + 2) == 0:
				return 0
		return 1


class Solution:

	def primeProduct(self, L, R):

		def p(n):
			if n == 0 or n == 1:
				return False
			if n == 2 or n == 3:
				return True
			if n % 2 == 0 or n % 3 == 0:
				return False
			for i in range(5, int(n ** 0.5) + 1, 6):
				if n % i == 0 or n % (i + 2) == 0:
					return False
			return True
		e = 1
		for i in range(L, R + 1):
			if p(i):
				e *= i
				e = e % (10 ** 9 + 7)
		return e % (10 ** 9 + 7)


import numpy
from math import sqrt

class Solution:

	def isPrime(self, n):
		limit = int(n ** 0.5)
		if n < 2:
			return False
		if n == 2:
			return True
		if n % 2 == 0:
			return False
		for i in range(3, limit + 1, 2):
			if n % i == 0:
				return False
		return True

	def primeProduct(self, l, r):
		prod = 1
		if l <= 2:
			prod = 2
		if l % 2 == 0:
			l += 1
		for i in range(l, r + 1, 2):
			if not self.isPrime(i):
				continue
			prod = prod * i
		return prod % 1000000007


import math

class Solution:

	def isPrime(self, n):
		loop = int(math.sqrt(n))
		if n < 2:
			return False
		if n == 2:
			return True
		if n % 2 == 0:
			return False
		for i in range(3, loop + 1, 2):
			if n % i == 0:
				return False
		return True

	def primeProduct(self, L, R):
		res = 1
		for i in range(L, R + 1):
			if self.isPrime(i):
				res *= i
			res = res % 1000000007
		return res % 1000000007


from math import sqrt, ceil

class Solution:

	def primeProduct(self, L, R):

		def _find_factors(R):
			N = ceil(sqrt(R)) + 1
			primes = [True] * (N + 1)
			primes[0] = primes[1] = False
			for i in range(2, ceil(sqrt(N)) + 2):
				if not primes[i]:
					continue
				for j in range(i * i, N + 1, i):
					primes[j] = False
			return primes
		MOD = 10 ** 9 + 7
		factors = _find_factors(R)
		primes = [True] * (R - L + 1)
		for i in range(len(factors)):
			if not factors[i]:
				continue
			fac = i
			for j in range(max(i * i, ceil(L / fac) * fac), R + 1, i):
				primes[j - L] = False
		ans = 1
		for i in range(len(primes)):
			if primes[i]:
				ans = ans * (i + L) % MOD
		return ans


def isPrime(n):
	limit = int(n ** 0.5)
	if n < 2:
		return False
	if n == 2:
		return True
	if n % 2 == 0:
		return False
	for i in range(3, limit + 1, 2):
		if n % i == 0:
			return False
	return True

class Solution:

	def primeProduct(self, L, R):
		prod = 1
		l = L
		r = R
		if l <= 2:
			prod = 2
		if l % 2 == 0:
			l += 1
		for i in range(l, r + 1, 2):
			if not isPrime(i):
				continue
			prod = prod * i
		return prod % 1000000007
if __name__ == '__main__':
	t = int(input())
	for _ in range(t):
		(L, R) = [int(x) for x in input().split()]
		ob = Solution()
		print(ob.primeProduct(L, R))


class Solution:

	def isPrime(self, n):
		limit = int(n ** 0.5)
		if n < 2:
			return False
		if n == 2:
			return True
		if n % 2 == 0:
			return False
		for i in range(3, limit + 1, 2):
			if n % i == 0:
				return False
		return True

	def primeProduct(self, L, R):
		prod = 1
		mod = 10 ** 9 + 7
		if L <= 2:
			prod = 2
		if L % 2 == 0:
			L += 1
		for i in range(L, R + 1, 2):
			if not self.isPrime(i):
				continue
			prod *= i
			prod %= mod
		return prod
if __name__ == '__main__':
	t = int(input())
	for _ in range(t):
		(L, R) = [int(x) for x in input().split()]
		ob = Solution()
		print(ob.primeProduct(L, R))


from math import sqrt, floor, ceil

class Solution:

	def primeProduct(self, L, R):
		r = floor(sqrt(R)) + 1
		Seen = [False for _ in range(r)]
		N = r
		i = 2
		while i * i <= N:
			if Seen[i]:
				i += 1
				continue
			for j in range(i * i, N, i):
				Seen[j] = True
			i += 1
		Primes = [i for i in range(2, r) if not Seen[i]]
		S = [False for _ in range(R - L + 1)]
		for x in Primes:
			(ll, rr) = (ceil(L / x), R // x)
			for j in range(max(ll, 2), rr + 1):
				S[x * j - L] = True
		res = 1
		M = 10 ** 9 + 7
		for i in range(R - L + 1):
			if not S[i]:
				res = res * (L + i) % M
		return res
if __name__ == '__main__':
	t = int(input())
	for _ in range(t):
		(L, R) = [int(x) for x in input().split()]
		ob = Solution()
		print(ob.primeProduct(L, R))


import math

def isprime(n):
	if n == 2:
		return True
	if n % 2 == 0:
		return False
	for i in range(3, int(math.sqrt(n)) + 1, 2):
		if n % i == 0:
			return False
	return True

class Solution:

	def primeProduct(self, l, r):
		m = 10 ** 9 + 7
		c = 1
		for i in range(l, r + 1):
			if isprime(i):
				c *= i % m
		return c % m
if __name__ == '__main__':
	t = int(input())
	for _ in range(t):
		(L, R) = [int(x) for x in input().split()]
		ob = Solution()
		print(ob.primeProduct(L, R))


class Solution:

	def isPrime(self, n):
		limit = int(n ** 0.5)
		if n < 2:
			return False
		if n == 2:
			return True
		if n % 2 == 0:
			return False
		for i in range(3, limit + 1, 2):
			if n % i == 0:
				return False
		return True

	def primeProduct(self, l, r):
		prod = 1
		if l <= 2:
			prod = 2
		if l % 2 == 0:
			l += 1
		for i in range(l, r + 1, 2):
			if not self.isPrime(i):
				continue
			prod = prod * i
		return prod % 1000000007


class Solution:

	def isprime(self, n):
		lim = int(n ** 0.5)
		if n < 2:
			return False
		if n == 2:
			return True
		if n % 2 == 0:
			return False
		for x in range(3, lim + 1, 2):
			if n % x == 0:
				return False
		return True

	def primeProduct(self, L, R):
		res = 1
		if L <= 2:
			res = 2
		if L % 2 == 0:
			L += 1
		for x in range(L, R + 1, 2):
			if not self.isprime(x):
				continue
			res *= x
		return res % (10 ** 9 + 7)


class Solution:

	def primeProduct(self, L, R):

		def isprime(n):
			limit = int(n ** 0.5)
			if n < 2:
				return False
			if n == 2:
				return True
			if n % 2 == 0:
				return False
			for i in range(3, limit + 1, 2):
				if n % i == 0:
					return False
			return True
		res = 1
		if L <= 2:
			res = 2
		if L % 2 == 0:
			L += 1
		for i in range(L, R + 1, 2):
			if isprime(i):
				res *= i
		return res % (10 ** 9 + 7)


from math import sqrt, floor, ceil

class Solution:

	def primeProduct(self, L, R):
		r = ceil(sqrt(R) + 1)
		prime = [1] * r
		for x in range(2, int(sqrt(r)) + 1):
			if prime[x]:
				for y in range(x * x, r, x):
					prime[y] = 0
		primes = []
		for x in range(2, r):
			if prime[x]:
				primes.append(x)
		prime = [1] * (R - L + 1)
		rslt = []
		for x in primes:
			index = ceil(L / x) * x
			for y in range(index, R + 1, x):
				if y != x:
					prime[y - L] = 0
		product = 1
		for x in range(R - L + 1):
			if prime[x]:
				product *= x + L
		return product % 1000000007


class Solution:

	def primeProduct(self, l, r):
		M = 10 ** 9 + 7

		def sieve(n):
			sieveList = [True for i in range(n + 1)]
			sieveList[0] = sieveList[1] = False
			i = 2
			while i * i <= n:
				for j in range(i * i, n + 1, i):
					sieveList[j] = False
				i += 1
			return [i for (i, x) in enumerate(sieveList) if x is True]

		def normalCase(lst, l):
			if l == 1:
				for i in lst:
					return lst
			else:
				for i in range(len(lst)):
					if lst[i] >= l:
						return lst[i:]
			return []

		def segmentedCase(lst, l, r):
			dummy = [True for i in range(r - l + 1)]
			for i in lst:
				firstMultiple = l // i * i
				if firstMultiple < l:
					firstMultiple += i
				for j in range(max(firstMultiple, i * i), r + 1, i):
					dummy[j - l] = False
			return [i + l for (i, x) in enumerate(dummy) if x is True]

		def calculate(l, r):
			if r - l > 10 ** 6:
				actualCase = normalCase(sieve(r), l)
				if actualCase == []:
					return 1
				else:
					product = 1
					for i in actualCase:
						product = product % M * (i % M) % M
					return product
			else:
				actualCase = segmentedCase(sieve(int(r ** 0.5)), l, r)
				if actualCase == []:
					return 1
				else:
					product = 1
					for i in actualCase:
						product = product % M * (i % M) % M
					return product
		return calculate(l, r)


import math

class Solution:

	def sieve(self, n):
		arr = [True] * (n + 1)
		p = 2
		while p * p <= n:
			if arr[p]:
				for j in range(p * p, n + 1, p):
					arr[j] = False
			p += 1
		primes = [2]
		for i in range(3, n + 1, 2):
			if arr[i]:
				primes.append(i)
		return primes

	def segmented(self, l, r):
		n = int(math.sqrt(r))
		primes = self.sieve(n)
		ans = [True] * (r - l + 1)
		i = 0
		while i < len(primes) and primes[i] * primes[i] <= r:
			b = l // primes[i] * primes[i]
			if b < l:
				b += primes[i]
			for j in range(b, r + 1, primes[i]):
				ans[j - l] = False
			if b == primes[i]:
				ans[b - l] = True
			i += 1
		p = []
		for i in range(0, r - l + 1):
			if ans[i]:
				p.append(l + i)
		return p

	def primeProduct(self, L, R):
		val = 10 ** 9 + 7
		pr = self.segmented(L, R)
		ans = 1
		for i in range(len(pr)):
			ans *= pr[i] % val
		return ans % val


class Solution:

	def primeProduct(self, L, R):

		def isPrime(n):
			if n <= 1:
				return False
			if n in [2, 3]:
				return True
			if n % 2 == 0 or n % 3 == 0:
				return False
			i = 5
			while i * i <= n:
				if n % i == 0 or n % (i + 2) == 0:
					return False
				i += 6
			return True
		res = 1
		while L <= R:
			if isPrime(L):
				res *= L
			L += 1
		return res % (10 ** 9 + 7)


import math

class Solution:

	def isprime(self, n):
		if n > 2 and n % 2 == 0:
			return False
		m = math.floor(math.sqrt(n))
		for i in range(3, m + 1, 2):
			if n % i == 0:
				return False
		return True

	def primeProduct(self, L, R):
		prod = 1
		for i in range(L, R + 1):
			if self.isprime(i):
				prod = prod * i
		return prod % (10 ** 9 + 7)


class Solution:

	def primeProduct(self, L, R):

		def isprime(n):
			if n <= 1:
				return False
			if n <= 3:
				return True
			if n % 2 == 0 or n % 3 == 0:
				return False
			j = 5
			while j * j <= n:
				if n % j == 0 or n % (j + 2) == 0:
					return False
				j += 6
			return True
		s = 1
		for i in range(L, R + 1):
			if isprime(i):
				s *= i
		return s % (10 ** 9 + 7)


class Solution:

	def primeProduct(self, L, R):

		def isPrime(val):
			if val <= 1:
				return False
			if val == 2 or val == 3:
				return True
			if val % 2 == 0 or val % 3 == 0:
				return False
			i = 5
			while i * i <= val:
				if val % i == 0:
					return False
				if val % (i + 2) == 0:
					return False
				i += 6
			return True
		ans = 1
		mod = 1000000007
		L = int(L % mod)
		R = int(R % mod)
		for i in range(L, R + 1):
			if isPrime(i):
				ans = int(ans * i % mod)
		return int(ans % mod)


class Solution:

	def isPrime(self, n):
		limit = int(n ** 0.5)
		if n < 2 or n == 2 or n % 2 == 0:
			return False
		for i in range(3, limit + 1, 2):
			if n % i == 0:
				return False
		return True

	def primeProduct(self, L, R):
		prod = 1
		if L <= 2:
			prod = 2
		if L % 2 == 0:
			L += 1
		for i in range(L, R + 1, 2):
			if not self.isPrime(i):
				continue
			prod *= i
		return prod % (10 ** 9 + 7)


class Solution:

	def isprime(self, x):
		limit = int(x ** 0.5)
		if x < 2:
			return False
		if x == 2:
			return True
		if x % 2 == 0:
			return False
		for i in range(3, limit + 1, 2):
			if x % i == 0:
				return False
		return True

	def primeProduct(self, L, R):
		prod = 1
		if L <= 2:
			prod = 2
		elif L % 2 == 0:
			L += 1
		for i in range(L, R + 1, 2):
			if not self.isprime(i):
				continue
			else:
				prod = prod * i
		return prod % 1000000007


import math

class Solution:

	def is_prime(self, num):
		temp_num = math.sqrt(num)
		if num <= 3:
			return True
		if num % 2 == 0 or num % 3 == 0:
			return False
		i = 5
		while i <= temp_num:
			if num % i == 0 or num % (i + 2) == 0:
				return False
			i += 6
		return True

	def primeProduct(self, L, R):
		res = 1
		for num in range(L, R + 1):
			if num > 1:
				if self.is_prime(num):
					res = res * num
		return res % 1000000007


class Solution:

	def is_prime(self, num):
		end = int(num ** 0.5)
		for i in range(3, end + 1, 2):
			if num % i == 0:
				return False
		return True

	def primeProduct(self, L, R):
		ans = 1
		if L == 1:
			L += 1
		if L % 2 == 0:
			if L == 2:
				ans *= 2
			L += 1
		for i in range(L, R + 1, 2):
			if self.is_prime(i):
				ans *= i
		return ans % (10 ** 9 + 7)


import math

class Solution:

	def isprime(self, n):
		for i in range(3, int(math.sqrt(n)) + 1, 2):
			if n % i == 0:
				return False
		return True

	def primeProduct(self, L, R):
		product = 1
		if L == 1 and R == 1:
			return 1
		if L <= 2:
			product = 2
		if L % 2 == 0:
			L += 1
		for i in range(L, R + 1, 2):
			if self.isprime(i):
				product *= i
		return product % (10 ** 9 + 7)


import math

class Solution:

	def primeProduct(self, L, R):
		mod = 1000000007
		ans = 1
		limit = int(math.sqrt(R))
		temp = [True for i in range(limit + 1)]
		i = 2
		while i * i < limit:
			for j in range(i + i, limit + 1, i):
				temp[j] = False
			i += 1
		te = []
		for i in range(2, limit + 1):
			if temp[i]:
				te.append(i)
		prime = [i for i in range(L, R + 1)]
		for i in te:
			k = L // i
			if k * i == L:
				st = L
			else:
				st = k * i + i
			if i == st:
				st += i
			for j in range(st, R + 1, i):
				prime[j - L] = False
		for i in prime:
			if i:
				ans = ans * i % mod
		return ans


import math

class Solution:

	def sieve_for_seg(self, n):
		prime = [True] * (n + 1)
		p = 2
		while p * p <= n:
			if prime[p] == True:
				for i in range(p * p, n + 1, p):
					prime[i] = False
			p += 1
		req = []
		for i in range(2, n + 1):
			if prime[i] == True:
				req.append(i)
		return req

	def segmented_sieve(self, low, high):
		if low <= 2:
			return self.sieve_for_seg(high)
		else:
			limit = math.floor(math.sqrt(high)) + 1
			prime = self.sieve_for_seg(limit)
			n = high - low + 1
			mark = [True] * (n + 1)
			for p in prime:
				low_map = math.ceil(low / p) * p
				if low_map == p:
					low_map += p
				for j in range(low_map, high + 1, p):
					mark[j - low] = False
			result = []
			for i in range(low, high + 1):
				if mark[i - low] == True:
					result.append(i)
			return result

	def primeProduct(self, L, R):
		res = self.segmented_sieve(L, R)
		ans = 1
		for r in res:
			ans = ans * r % 1000000007
		return ans


import math

class Solution:

	def primeProduct(self, L, R):
		mul = 1
		if L <= 2:
			mul = 2
		if L % 2 == 0:
			L += 1
		for i in range(L, R + 1, 2):
			if not isPrime(i):
				continue
			mul *= i
		return mul % 1000000007

def isPrime(num):
	if num <= 1:
		return False
	if num % 2 == 0:
		return False
	else:
		for i in range(3, int(math.sqrt(num)) + 1, 2):
			if num % i == 0:
				return False
	return True


class Solution:

	def isprime(self, n):
		r = int(n ** 0.5)
		if n < 2:
			return False
		if n == 2:
			return True
		if n % 2 == 0:
			return False
		for i in range(3, r + 1, 2):
			if n % i == 0:
				return False
		return True

	def primeProduct(self, L, R):
		p = 1
		for i in range(L, R + 1):
			if not self.isprime(i):
				continue
			p *= i
		return p % 1000000007


import numpy

class Solution:

	def isPrime(self, n):
		limit = int(n ** 0.5)
		if n < 2:
			return False
		if n == 2:
			return True
		if n % 2 == 0:
			return False
		for i in range(3, limit + 1, 2):
			if n % i == 0:
				return False
		return True

	def primeProduct(self, L, R):
		prod = 1
		if L <= 2:
			prod = 2
		if L % 2 == 0:
			L += 1
		for i in range(L, R + 1, 2):
			if not self.isPrime(i):
				continue
			prod = prod * i
		return prod % 1000000007