G. [2024 GDCPC G]Menji 和 gcd

    Type: Default 2000ms 256MiB

[2024 GDCPC G]Menji 和 gcd

You cannot submit for this problem because the contest is ended. You can click "Open in Problem Set" to view this problem in normal mode.

Background

Special for beginners, ^_^

Description

Menji 喜欢最大公约数,特别是最大公约数大的正整数对。

令 gcd⁡(x,y)\gcd(x,y) 表示 x,yx,y 的最大公约数,多次给定 L,RL,R,保证 L<RL<R,求 max⁡L≤x<y≤Rgcd⁡(x,y)\max\limits_{L\leq x<y\leq R}\gcd(x,y)。

Format

Input

第一行一个正整数 T(1≤T≤10)T(1\leq T\leq 10),表示数据组数。

之后 TT 行,每行两个正整数 L,R(1≤L<R≤1012)L,R(1\leq L<R\leq 10^{12}),表示一组询问。

Output

对于每个询问 L,RL,R,输出一行一个正整数 max⁡L≤x<y≤Rgcd⁡(x,y)\max\limits_{L\leq x<y\leq R}\gcd(x,y)。

Samples

10
1 2
2 4
6 10
11 21
147 154
1470 1540
2890 3028
998244353 1000000007
34827364537 41029384775
147147147147 154154154154
1
2
3
7
7
70
126
1754385
5861340682
7007007007

Limitation

2s, 1024KiB for each test case.