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: import java.util.ArrayList;
  import java.util.Collections;
  import java.util.HashMap;
  import java.util.HashSet;
  import java.util.PriorityQueue;
  import java.util.StringTokenizer;
   
   
  import java.io.*;
   
  public class Div2 {
  	
  	private static class MyScanner {
  	    BufferedReader br;
  	    StringTokenizer st;
   
  	    public MyScanner() {
  	       br = new BufferedReader(new InputStreamReader(System.in));
  	    }
   
  	    String next() {
  	        while (st == null || !st.hasMoreElements()) {
  	            try {
  	                st = new StringTokenizer(br.readLine());
  	            } catch (IOException e) {
  	                e.printStackTrace();
  	            }
  	        }
  	        return st.nextToken();
  	    }
   
  	    int nextInt() {
  	        return Integer.parseInt(next());
  	    }
   
  	    long nextLong() {
  	        return Long.parseLong(next());
  	    }
   
  	    double nextDouble() {
  	        return Double.parseDouble(next());
  	    }
   
  	    String nextLine(){
  	        String str = "";
  		  try {
  		     str = br.readLine();
  		  } catch (IOException e) {
  		     e.printStackTrace();
  		  }
  		  return str;
  	    }
   
  	 }
  	
      public static int solution(int x, int y)
      {
      	int n = -1;
      	
      	if(x==y)
      		n = x;
      	else if(x>y)
      		n = x+y;
      	else
             n = y - (y%x)/2;
         
         return n;
      }
          
  private static PrintWriter out = new PrintWriter(System.out);
   
  public static void main (String[] args)
  {
  	MyScanner s =  new MyScanner();
     	  
      int t = s.nextInt();
      
      while(t-->0)
      {
  		int x = s.nextInt();
  		int y = s.nextInt();
  		
          out.println(solution(x,y));
      }
           
      out.flush();
      out.close();
      
  }
  }