Product of Primes
Submissions: 2198   Accuracy:

13.93%

  Difficulty: Medium   Marks: 4

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.
 

Input
The first line of the input contains T the number of test cases.  Then T lines follow. Each test case contains one line , having two values L and which denotes the range of the numbers.

Output
For each test case print the product modulo 10^9+7 in a new line.

 

Constraints :             
1<=T<=50

1<=L,R<=10^9

0<=R-L<=10^6
 

Example

Input
 2
 1 10
 1 20


 Output : 
 210
 9699690


Explanation :

For the first test case, primes are 2,3,5,7. and their product is 2*3*5*7=210.

For the second test case primes are 2,3,5,7,11,13,17,19. and their product is  9699690.

** For More Input/Output Examples Use 'Expected Output' option **

Author: Arnab Deb


If you have purchased any course from GeeksforGeeks then please ask your doubt on course discussion forum. You will get quick replies from GFG Moderators there.



Need help with your code? Please use ide.geeksforgeeks.org, generate link and share the link here.


to report an issue on this page.