YouKn0wWho has two even integers x and y. Help him to find an integer n such that 1 ≤ n ≤ 2 ⋅ 10^{18} and n mod x = y mod n. Here, a mod 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 ≤ t ≤ 10^5) — the number of test cases.

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

Output

For each test case, print a single integer n (1 ≤ n ≤ 2 ⋅ 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.

Example

Input


4
4 8
4 2
420 420
69420 42068


Output


4
10
420
9969128

Note

In the first test case, 4 mod 4 = 8 mod 4 = 0.

In the second test case, 10 mod 4 = 2 mod 10 = 2.

In the third test case, 420 mod 420 = 420 mod 420 = 0.
1
1000000000 1000000000

1000000000 

# from collections import defaultdict
import math
# import sys
# sys.setrecursionlimit(400000)
from itertools import chain, groupby
from functools import reduce
from math import comb, gcd # n! / (k! * (n - k)!)
from collections import defaultdict
from sys import stdout
 
 
NO = 'NO'
YES = 'YES'
MOD = 1000000007
ALPH = 'abcdefghijklmnopqrstuvwxyz'
 
def input_int():
    return int(input())
 
def input_list():
    return input().split(' ')
 
def input_list_int():
    return list(map(int, input_list()))
 
def list_int_to_str(a, sep = ' '):
    return sep.join(str(x) for x in a) 
 
global_ans = []
def pr(a):
    global_ans.append(a)
 
def z_func(s):
    n = len(s)
    z = [0] * n
    l = r = 0
    for i in range(1, n):
        if r >= i:
            z[i] = min(z[i - l], r - i + 1)
        while z[i] + i < n and s[z[i]] == s[z[i] + i]:
            z[i] += 1
        if i + z[i] - 1 > r:
            l = i
            r = i + z[i] - 1
    return z
 
def is_prime(n):
    d = 2
    while n % d != 0:
        d += 1
    return d == n

def partial_sum(a):
    b = [0]
    for i in a:
        b.append(b[-1] ^ i)
    return b

def partial_sum_2d(a):
    n = len(a)
    if n == 0:
        return []
    m = len(a[0])
    b = []
    for i in range(n + 1):
        b.append([0] * (m + 1))
    for i in range(n):
        for j in range(m):
            b[i + 1][j + 1] = a[i][j] + b[i][j + 1] + b[i + 1][j] - b[i][j]
    return b


def dfs_paths(graph, start, goal):
    stack = [(start, [start])]
    visited = set()
    while stack:
        (vertex, path) = stack.pop()
        if vertex not in visited:
            if vertex == goal:
                return path
            visited.add(vertex)
            for neighbor in graph[vertex]:
                stack.append((neighbor, path + [neighbor]))

def dfs(g, v, s, n):
    visited = [0] * (n + 1)
    def dfs_util(v, s):
        if v == s:
            return 1
        if visited[v]:
            return 0
        visited[v] = 1
        for i in g[v]:
            if not visited[i]:
                lr = dfs_util(i, s)
                if lr:
                    return 1
        return 0
    return dfs_util(v, s)

def solve():
    x, y = input_list_int()
    ans = -1
    if x > y:
        ans = x + y
    elif y % x == 0:
        ans = x
    else:
        ans = (x + y) // 2
    # print('t = ', ans % x, y % ans)
    pr(ans)


query_count = 1
query_count = input_int()
 
 
while query_count:
    query_count -= 1
    solve()
 
for global_ans_line in global_ans:
    if isinstance(global_ans_line, list):
        print(' '.join(str(x) for x in global_ans_line)) 
    else:
        print(global_ans_line)
 
 