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 

import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.*;

public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        Solution solver = new Solution();
        boolean multipleTC = true;
        int testCount = multipleTC ? Integer.parseInt(in.next()) : 1;
        for (int i = 1; i <= testCount; i++) solver.solve(in, out, i);
        out.close();
    }

    static class Solution {
        PrintWriter out;
        InputReader in;

        public void solve(InputReader in, PrintWriter out, int test) {
            this.out = out;
            this.in = in;



            //for(int i = 1; i <= 100; i++) {
                int x = ni(), y = ni();
                int ans = -1;
                // for(int x = 2; x <= 200; x += 2) {
                //     for(int y = 2; y <= 200; y += 2) {

                //     }
                // }
                int gcd, a, b, mod = 0;
                if (x > y)
                    ans = (x + y);
                else {
                    gcd = gcd(x, y);
                    a = x / gcd;
                    b = y / gcd;
                    mod = b % a;
                    int cnt = 1;
                    while(true) {
                        int curr = y - cnt * mod;
                        if(curr % x == y % curr) {
                            ans = curr;
                            break;
                        }
                        cnt++;
                    }
                }
                // if(ans % x != y % ans) {
                //     pn(x + " " + y + " " + ans + " " + mod + " " + "Hola");
                //     for(int n = 1; n <= 500; n++) {
                //         if(n % x == y % n) {
                //             pn(x + " " + y + " " + n + " " + n % x);
                //         }
                //     }
                // }
            //}
            pn(ans);
        }

        String n() {
            return in.next();
        }

        int ni() {
            return in.nextInt();
        }

        long nl() {
            return in.nextLong();
        }

        void pn(long zx) {
            out.println(zx);
        }

        void pn(String sz) {
            out.println(sz);
        }

        void pn(double dx) {
            out.println(dx);
        }

        int gcd(int a, int b) {
            if (a == 0)
                return b;
            return gcd(b%a, a);
        }


    }

    static class InputReader {
        private InputStream stream;
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;

        public InputReader(InputStream stream) {
            this.stream = stream;
        }

        public int read() {
            if (numChars == -1) {
                throw new UnknownError();
            }
            if (curChar >= numChars) {
                curChar = 0;
                try {
                    numChars = stream.read(buf);
                } catch (IOException e) {
                    throw new UnknownError();
                }
                if (numChars <= 0) {
                    return -1;
                }
            }
            return buf[curChar++];
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

        public long nextLong() {
            return Long.parseLong(next());
        }

        public String next() {
            int c = read();
            while (isSpaceChar(c)) {
                c = read();
            }
            StringBuffer res = new StringBuffer();
            do {
                res.appendCodePoint(c);
                c = read();
            } while (!isSpaceChar(c));

            return res.toString();
        }

        private boolean isSpaceChar(int c) {
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }
    }
}
