ABA12A - Help Balaji!

no tags 

Balaji was reading number theory. When reading about primes, he was thinking about numbers which could be expressed as a product of primes. He wanted to know the largest number in a range which could be expressed as a product of primes. Balaji’s maths teacher is not so good at maths and so he was taught that 1 is prime. You, being a good programmer, help him with the task.

Input

The first line of input consists of C, the number of test cases, followed by C lines containing two space separated numbers a and b, the first and last number in the range (inclusive).

1 < C < 100

0 < A < B < 1e12

0 < B - A < 1e6

Output

For each test case, print a single line containing the largest number which can be represented as a product of primes, considering 1 to be prime.

Example

Input:
1
1 4

Output:
4

Explanation of Test Case

4 can be expressed as 2 × 2.


hide comments
Nnavneetsinha: 2012-01-24 01:46:49

got to know something new from this problem

Last edit: 2012-01-22 05:47:15
Danang Prawira Nugraha: 2012-01-24 01:46:49

1 < A < B < 1e12
but in the example A = 1 ? :/

saket diwakar: 2012-01-24 01:46:49

tutorial question.....

conioh: 2012-01-24 01:46:49

:)

mehmetin: 2012-01-24 01:46:49

Last edit: 2012-01-17 17:08:36
PubLic_AvenGeR: 2012-01-24 01:46:49

definitely tutorial :\\\

! include(L.ppt): 2012-01-24 01:46:49

tutorial!!!!!!!

Sharavana guru: 2012-01-24 01:46:49

Move to tutorial.But its tricky good:-)

killerz: 2012-01-24 01:46:49

Move to tutorial

[Retired] Fendy Kosnatha: 2012-01-24 01:46:49

what the answer for a=1 and b=8??

Last edit: 2012-01-17 10:37:32

Added by:Kashyap Krishnakumar
Date:2012-01-10
Time limit:1s
Source limit:50000B
Memory limit:1536MB
Cluster: Cube (Intel G860)
Languages:All except: ASM64
Resource:Own problem