Product of Primes
Medium Accuracy: 20.37% Submissions: 4424 Points: 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.

to report an issue on this page.

Editorial

We strongly recommend solving this problem on your own before viewing its editorial. Do you still want to view the editorial?

Yes

All Submissions

My Submissions:

Login to access your submissions.