Codeforces Round 752 (Div. 1)
B
Moderate Modular Mode
Codeforces
1600
原题
← AC →
翻译中…

YouKn0wWho has two even integers $x$ and $y$. Help him to find an integer $n$ such that $1 \le n \le 2 \cdot 10^{18}$ and $n \bmod x = y \bmod n$. Here, $a \bmod b$ denotes the remainder of $a$ after division by $b$. If there are multiple such integers, output any. It can be shown that such an integer always exists under the given constraints.

翻译中…

Input

翻译中…

The first line contains a single integer $t$ ($1 \le t \le 10^5$)  — the number of test cases.

翻译中…

The first and only line of each test case contains two integers $x$ and $y$ ($2 \le x, y \le 10^9$, both are even).

翻译中…

Output

翻译中…

For each test case, print a single integer $n$ ($1 \le n \le 2 \cdot 10^{18}$) that satisfies the condition mentioned in the statement. If there are multiple such integers, output any. It can be shown that such an integer always exists under the given constraints.

翻译中…

Note

翻译中…

In the first test case, $4 \bmod 4 = 8 \bmod 4 = 0$.

翻译中…

In the second test case, $10 \bmod 4 = 2 \bmod 10 = 2$.

翻译中…

In the third test case, $420 \bmod 420 = 420 \bmod 420 = 0$.

翻译中…

样例

Input #1
4
4 8
4 2
420 420
69420 42068
Output #1
4
10
420
9969128
InputCopy OutputCopy
题目信息
题号
1603B
时间限制
1 s
内存限制
256 MB
标签
构造
数学
数论

题面与样例版权归 Codeforces 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。