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 

// Problem: D. Moderate Modular Mode
// Contest: Codeforces - Codeforces Round #752 (Div. 2)
// URL: https://codeforces.com/contest/1604/problem/D
// Memory Limit: 256 MB
// Time Limit: 1000 ms
// 
// Powered by CP Editor (https://cpeditor.org)

import java.io.*;
import java.util.*;

import static java.lang.Math.max;
import static java.lang.Math.min;
import static java.lang.Math.abs;



public class Main {

    private void preparation() {

    }


    private void clear() {

    }

    private void solve() throws Exception {
        rf();
        long x = rl();
        long y = rl();
		
		long ans = 0;
		if(x < y){
		    ans = (y / x * x + y) / 2;
		}else if(x == y){
		    ans = x;
		}else{
		    ans = x + y;
		}
		
		addAns(ans);
    }

    private void run() throws Exception {
		
        int T = 1;
		rf();
		T = ri();
		
		preparation();
        while (T-- > 0) {
            solve();
            if (T != 0) {
                clear();
            }
        }
        printAns();
    }

    public static void main(String[] args) throws Exception {
        new Main().run();
    }

    StringBuilder sb = new StringBuilder();
    BufferedReader infile = new BufferedReader(new InputStreamReader(System.in));
    StringTokenizer strT;

	private void addAns(int a){
		sb.append(a + "\n");
	}
	
	private void addAns(long a){
		sb.append(a + "\n");
	}
	
	private void addAns(String s){
		sb.append(s + "\n");
	}

    private void rf() throws IOException {
        strT = new StringTokenizer(infile.readLine());
    }


    private int ri() {
        return Integer.parseInt(strT.nextToken());
    }

    private long rl() {
        return Long.parseLong(strT.nextToken());
    }

	private char [] rs2c(){
		return strT.nextToken().toCharArray();
	}
	
	private String rs(){
		return strT.nextToken();
	}

    private void printAns() {
        System.out.println(sb);
    }

    private int[] readArr(int N) throws Exception {
        int[] arr = new int[N];
        for (int i = 0; i < N; i++) {
            arr[i] = Integer.parseInt(strT.nextToken());
        }
        return arr;
    }

	private long[] readArr2(int N) throws Exception {
        long[] arr = new long[N];
        for (int i = 0; i < N; i++) {
            arr[i] = Long.parseLong(strT.nextToken());
        }
        return arr;
    }

	private void print(String format, Object ... args){
		System.out.println(String.format(format,args));
	}
	

    private void print(int[] arr, int x) {
        //for debugging only
        for (int i = 0;i < min(arr.length, x); i++) {
            System.out.print(arr[i] + " ");
        }
        System.out.println();
    }
    
    private void print(long[] arr, int x) {
        //for debugging only
        for (int i = 0;i < min(arr.length, x); i++) {
            System.out.print(arr[i] + " ");
        }
        System.out.println();
    }

    
}
