310975: CF1916B. Two Divisors

Memory Limit:256 MB Time Limit:1 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

B. Two Divisorstime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard output

A certain number $1 \le x \le 10^9$ is chosen. You are given two integers $a$ and $b$, which are the two largest divisors of the number $x$. At the same time, the condition $1 \le a < b < x$ is satisfied.

For the given numbers $a$, $b$, you need to find the value of $x$.

$^{\dagger}$ The number $y$ is a divisor of the number $x$ if there is an integer $k$ such that $x = y \cdot k$.

Input

Each test consists of several test cases. The first line contains a single integer $t$ ($1 \le t \le 10^4$) — the number of test cases. Then follows the description of the test cases.

The only line of each test cases contains two integers $a$, $b$ ($1 \le a < b \le 10^9$).

It is guaranteed that $a$, $b$ are the two largest divisors for some number $1 \le x \le 10^9$.

Output

For each test case, output the number $x$, such that $a$ and $b$ are the two largest divisors of the number $x$.

If there are several answers, print any of them.

ExampleInput
8
2 3
1 2
3 11
1 5
5 10
4 6
3 9
250000000 500000000
Output
6
4
33
25
20
12
27
1000000000
Note

For the first test case, all divisors less than $6$ are equal to $[1, 2, 3]$, among them the two largest will be $2$ and $3$.

For the third test case, all divisors less than $33$ are equal to $[1, 3, 11]$, among them the two largest will be $3$ and $11$.

For the fifth test case, all divisors less than $20$ are equal to $[1, 2, 4, 5, 10]$, among them the two largest will be $5$ and $10$.

For the sixth test case, all divisors less than $12$ are equal to $[1, 2, 3, 4, 6]$, among them the two largest will be $4$ and $6$.

Output

题目大意:
给定两个整数a和b,它们是一个数x的最大两个除数,同时满足1≤a
输入数据格式:
每个测试包含多个测试用例。第一行包含一个整数t(1≤t≤10^4)——测试用例的数量。接下来是测试用例的描述。
每个测试用例仅包含一行,有两个整数a和b(1≤a 保证a和b是某个数1≤x≤10^9的最大两个除数。

输出数据格式:
对于每个测试用例,输出一个数x,使得a和b是该数x的最大两个除数。
如果有多个答案,输出其中任意一个。

示例:
输入
8
2 3
1 2
3 11
1 5
5 10
4 6
3 9
250000000 500000000
输出
6
4
33
25
20
12
27
1000000000

注意:
在第一个测试用例中,所有小于6的除数等于[1, 2, 3],其中最大的两个是2和3。
在第三个测试用例中,所有小于33的除数等于[1, 3, 11],其中最大的两个是3和11。
在第五个测试用例中,所有小于20的除数等于[1, 2, 4, 5, 10],其中最大的两个是5和10。
在第六个测试用例中,所有小于12的除数等于[1, 2, 3, 4, 6],其中最大的两个是4和6。题目大意: 给定两个整数a和b,它们是一个数x的最大两个除数,同时满足1≤a

加入题单

上一题 下一题 算法标签: