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.util.StringTokenizer;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.lang.reflect.Array;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.math.BigInteger;
import java.util.Arrays;
import java.util.Collections;
import java.util.ArrayList;

public class p4
{
	BufferedReader br;
	StringTokenizer st;
	BufferedWriter bw;
	public static void main(String[] args)throws Exception
	{
		new p4().run();
	}

	void run()throws IOException
	{
		br = new BufferedReader(new InputStreamReader(System.in));
		bw=new BufferedWriter(new OutputStreamWriter(System.out));

		solve();
	}
	void solve() throws IOException
	{
		int t=ni();
		while(t-->0)
		{
			int x=ni();
			int y=ni();

			if(y%x==0)
				System.out.println(x);
			else if(x>y)
				System.out.println(x+y);
			else
				System.out.println((x+y)/2);
		}
	}

/*
y=ax, n=x
x>y, n=x+y
y>x, 


*/




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

	int[] nai(int n) { int a[]=new int[n]; for(int i=-1;++i<n;)a[i]=ni();	return a;}

	long[] nal(int n) { long a[]=new long[n]; for(int i=-1;++i<n;)a[i]=nl();	return a;}

	char[] nac()	{char c[]=nextLine().toCharArray();	return c;}

	char [][] nmc(int n)	{char c[][]=new char[n][]; for(int i=-1;++i<n;)c[i]=nac();	return c;}

	int[][] nmi(int r, int c)	{int a[][]=new int[r][c]; for(int i=-1;++i<r;)a[i]=nai(c);	return a;}

	String next()
	{
			while (st == null || !st.hasMoreElements()) {
					try {
							st = new StringTokenizer(br.readLine());
					}
					catch (IOException e) {
							e.printStackTrace();
					}
			}
			return st.nextToken();
	}

	int ni() { return Integer.parseInt(next()); }

	byte nb() { return Byte.parseByte(next()); }

	short ns() { return Short.parseShort(next()); }

	long nl() { return Long.parseLong(next()); }

	double nd()	{	return Double.parseDouble(next());	}

	String nextLine()
	{
			String str = "";
			try {
					str = br.readLine();
			}
			catch (IOException e) {
					e.printStackTrace();
			}
			return str;
	}

	int countDigits(int l)	{
		if (l >= 1000000000) return 10;
		if (l >= 100000000) return 9;
		if (l >= 10000000) return 8;
		if (l >= 1000000) return 7;
		if (l >= 100000) return 6;
		if (l >= 10000) return 5;
		if (l >= 1000) return 4;
		if (l >= 100) return 3;
		if (l >= 10) return 2;
		return 1;
	}
	int countDigits(long l) {
		if (l >= 1000000000000000000L) return 19;
		if (l >= 100000000000000000L) return 18;
		if (l >= 10000000000000000L) return 17;
		if (l >= 1000000000000000L) return 16;
		if (l >= 100000000000000L) return 15;
		if (l >= 10000000000000L) return 14;
		if (l >= 1000000000000L) return 13;
		if (l >= 100000000000L) return 12;
		if (l >= 10000000000L) return 11;
		if (l >= 1000000000L) return 10;
		if (l >= 100000000L) return 9;
		if (l >= 10000000L) return 8;
		if (l >= 1000000L) return 7;
		if (l >= 100000L) return 6;
		if (l >= 10000L) return 5;
		if (l >= 1000L) return 4;
		if (l >= 100L) return 3;
		if (l >= 10L) return 2;
		return 1;
	}
}