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 

    // package Codeforces.CF752;
    
    import java.io.BufferedReader;
    import java.io.IOException;
    import java.io.InputStreamReader;
    import java.io.PrintWriter;
    import java.util.Arrays;
    import java.util.StringTokenizer;
    
    public class D {
    
        static final long mod = (long) 1e9 + 7l;
    
        private static void solve(int t) {
            int a = fs.nextInt();
            int b = fs.nextInt();
            if(a<=b) {
                int pos = b- (b%a)/2;
                out.println(pos);
            }
            else out.println(a+b);
        }
    
    
        public static void main(String[] args) {
            fs = new FastScanner();
            out = new PrintWriter(System.out);
            long s = System.currentTimeMillis();
            int t = fs.nextInt();
            for (int i = 1; i <= t; i++) solve(t);
            out.close();
    //        System.err.println( System.currentTimeMillis() - s + "ms" );
        }
    
        static boolean DEBUG = true;
        static PrintWriter out;
        static FastScanner fs;
    
        static void trace(Object... o) {
            if (!DEBUG) return;
            System.err.println(Arrays.deepToString(o));
        }
    
        static void pl(Object o) {
            out.println(o);
        }
    
        static void p(Object o) {
            out.print(o);
        }
    
        static long gcd(long a, long b) {
            return (b == 0) ? a : gcd(b, a % b);
        }
    
        static int gcd(int a, int b) {
            return (b == 0) ? a : gcd(b, a % b);
        }
    
        static void sieveOfEratosthenes(int n, int factors[]) {
            factors[1] = 1;
            for (int p = 2; p * p <= n; p++) {
                if (factors[p] == 0) {
                    factors[p] = p;
                    for (int i = p * p; i <= n; i += p)
                        factors[i] = p;
                }
            }
        }
    
        static long mul(long a, long b) {
            return a * b % mod;
        }
    
        static long fact(int x) {
            long ans = 1;
            for (int i = 2; i <= x; i++) ans = mul(ans, i);
            return ans;
        }
    
        static long fastPow(long base, long exp) {
            if (exp == 0) return 1;
            long half = fastPow(base, exp / 2);
            if (exp % 2 == 0) return mul(half, half);
            return mul(half, mul(half, base));
        }
    
        static long modInv(long x) {
            return fastPow(x, mod - 2);
        }
    
        static long nCk(int n, int k) {
            return mul(fact(n), mul(modInv(fact(k)), modInv(fact(n - k))));
        }
    
        static class FastScanner {
            BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
            StringTokenizer st = new StringTokenizer("");
    
            public String next() {
                while (!st.hasMoreElements())
                    try {
                        st = new StringTokenizer(br.readLine());
                    } catch (IOException e) {
                        e.printStackTrace();
                    }
                return st.nextToken();
            }
    
            int nextInt() {
                return Integer.parseInt(next());
            }
    
            int[] readArray(int n) {
                int[] a = new int[n];
                for (int i = 0; i < n; i++)
                    a[i] = nextInt();
                return a;
            }
    
            long nextLong() {
                return Long.parseLong(next());
            }
        }
    }
