description: 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.
solution: //package Codeforces;
  import java.util.*;
  
  import java.io.*;
  public  class template{
  	
  	static class FastScanner {
  		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
  		StringTokenizer st = new StringTokenizer("");
  		String next () {
  			while(!st.hasMoreTokens()) {
  				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());
  		}
  	}
  	
  	static class helper{
  		
  		//reverse 1-d Array
  		public static void reverse(int arr[]) {
  			int i = 0;
  			int j = arr.length - 1;
  			while(i<j) {
  				int temp = arr[i];
  				arr[i] = arr[j];
  				arr[j] = temp;
  			}
  		}
  		
  		//gcd of two numbers
  		public static int gcd(int a,int b) {
  			if(b == 0) {
  				return a;
  			}
  			return gcd(b,a%b);
  		}
  		
  		//calculate ncr
  		public static int ncr(int n,int r) {
  			int num = n;
  			int deno = r;
  			int a1 = 1;
  			int a2 = 1;
  			for(int i=0;i<r;i++) {
  				a1 *= num;
  				a2 *= deno;
  				num--;
  				deno--;
  			}
  			int ans = a1/a2;
  			return ans;
  		}
  		
  		//isPalindrome
  		public static boolean isPalindrome(String substring){
  		    char ch[] = substring.toCharArray();
  		    int i = 0;
  		    int j = ch.length-1;
  		    while(i<j){
  		        char temp = ch[i];
  		        ch[i] = ch[j];
  		        ch[j] = temp;
  		        i++;
  		        j--;
  		    }
  		    String rev = String.valueOf(ch);
  		    if(rev.equals(substring)){
  		        return true;
  		    }
  		    else{
  		        return false;
  		    }
  		}
  		
  		//isPowerOfTwo
  		public static boolean isPowerOfTwo(long x)
  	    {
  	        /* First x in the below expression is
  	        for the case when x is 0 */
  	        return x != 0 && ((x & (x - 1)) == 0);
  	    }
  		
  		//nextPowerOfTwo
  		public static long nextPowerOfTwo(long n)
  	    {
  	        n--;
  	        n |= n >> 1;
  	        n |= n >> 2;
  	        n |= n >> 4;
  	        n |= n >> 8;
  	        n |= n >> 16;
  	        n++;
  	         
  	        return n;
  	    }
  	}
  	
  
  	
  	public static void main(String[] args) {
  		  FastScanner sc = new FastScanner();
  		  PrintWriter out = new PrintWriter(System.out);
  		  helper help = new helper();
  		  long test = sc.nextLong();
  		  while(test-->0) {
  			  long x = sc.nextLong();
  			  long y = sc.nextLong();
  			  if(x == y) {
  				  out.println(x);
  			  }
  			  else if(x < y) {
  				  if(y%x == 0) {
  					  out.println(x);
  				  }
  				  else {
  					  long ans = y/x;
  					  long a = ans * x;
  					  out.println((a+y)/2);	  
  				  }
  				
  			  }
  			  else{
  				  out.println(x+y);
  			  }
  		  }
  		  out.flush();
  	}
  	
  }
  
  class pair {
  	int value;
  	int index;
  	pair(int value,int index){
  		this.value = value;
  		this.index = index;
  	}
  	public int getValue() {
  		return value;
  	}
  	public void setValue(int value) {
  		this.value = value;
  	}
  	public int getIndex() {
  		return index;
  	}
  	public void setIndex(int index) {
  		this.index = index;
  	}
  }
  