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.io.*;
  import java.util.*;
  
  public class Main {
      static PrintWriter pw;
      static Scanner sc;
      static long ceildiv(long x, long y) { return (x+y-1) / y; }
      static int mod(long x, int m) { return (int) ((x%m + m) % m); }
      static void put(Map<Integer, Integer> map, Integer p){if(map.containsKey(p)) map.replace(p, map.get(p)+1); else map.put(p, 1); }
      static void rem(Map<Integer, Integer> map, Integer p){ if(map.get(p)==1) map.remove(p); else map.replace(p, map.get(p)-1); }
      static int Int(boolean x){ return x ? 1 : 0; }
      static final int inf=(int)1e9, mod= inf + 7;
      static final long infL=inf*1l*inf;
      static final double eps=1e-9;
      public static long gcd(long x, long y) { return y==0? x: gcd(y, x%y); }
      public static void main(String[] args) throws Exception {
          sc = new Scanner(System.in);
          pw = new PrintWriter(System.out);
          int t = sc.nextInt();
          while (t-- > 0)
              testCase();
          pw.close();
      }
  
      static void testCase() throws Exception{
          int x = sc.nextInt(), y = sc.nextInt();
          if(x > y){
              pw.println((x+1) * 1l * y);
              return;
          }
          pw.println(y - (y%x)/2);
      }
  
  
      static void printArr(int[] arr) {
          for (int i = 0; i < arr.length; i++)
              pw.print(arr[i] + " ");
          pw.println();
      }
  
      static void printArr(long[] arr) {
          for (int i = 0; i < arr.length; i++)
              pw.print(arr[i] + " ");
          pw.println();
      }
  
      static void printArr(double[] arr) {
          for (int i = 0; i < arr.length; i++)
              pw.print(arr[i] + " ");
          pw.println();
      }
  
      static void printArr(Integer[] arr) {
          for (int i = 0; i < arr.length; i++)
              pw.print(arr[i] + " ");
          pw.println();
      }
  
      static void printIter(Iterable list) {
          for (Object o : list)
              pw.print(o + " ");
          pw.println();
      }
  
      static class Scanner {
          StringTokenizer st;
          BufferedReader br;
  
          public Scanner(InputStream s) {
              br = new BufferedReader(new InputStreamReader(s));
          }
  
          public Scanner(FileReader r) {
              br = new BufferedReader(r);
          }
  
          public String next() throws IOException {
              while (st == null || !st.hasMoreTokens())
                  st = new StringTokenizer(br.readLine());
              return st.nextToken();
          }
  
          public int nextInt() throws IOException {
              return Integer.parseInt(next());
          }
  
          public long nextLong() throws IOException {
              return Long.parseLong(next());
          }
  
          public String nextLine() throws IOException {
              return br.readLine();
          }
  
          public double nextDouble() throws IOException {
              return Double.parseDouble(next());
          }
  
          public int[] nextDigits() throws IOException {
              String s = nextLine();
              int[] arr = new int[s.length()];
              for (int i = 0; i < arr.length; i++)
                  arr[i] = s.charAt(i) - '0';
              return arr;
          }
  
          public int[] nextArr(int n) throws IOException {
              int[] arr = new int[n];
              for (int i = 0; i < arr.length; i++)
                  arr[i] = nextInt();
              return arr;
          }
  
          public Integer[] nextsort(int n) throws IOException {
              Integer[] arr = new Integer[n];
              for (int i = 0; i < n; i++)
                  arr[i] = nextInt();
              return arr;
          }
  
          public Pair nextPair() throws IOException {
              return new Pair(nextInt(), nextInt());
          }
  
          public long[] nextLongArr(int n) throws IOException {
              long[] arr = new long[n];
              for (int i = 0; i < n; i++)
                  arr[i] = nextLong();
              return arr;
          }
  
          public Pair[] nextPairArr(int n) throws IOException {
              Pair[] arr = new Pair[n];
              for (int i = 0; i < n; i++)
                  arr[i] = nextPair();
              return arr;
          }
  
          public boolean hasNext() throws IOException {
              return (st != null && st.hasMoreTokens()) || br.ready();
          }
      }
  
      static class Pair implements Comparable<Pair> {
          int x;
          int y;
  
          public Pair(int x, int y) {
              this.x = x;
              this.y = y;
          }
  
          public Pair(Map.Entry<Integer, Integer> a) {
              x = a.getKey();
              y = a.getValue();
          }
  
          public int hashCode() {
              return (int) ((this.x*1l*100003 + this.y) % mod);
          }
  
          public int compareTo(Pair p) {
              if(x != p.x)
                  return x - p.x;
              return y - p.y;
          }
  
          public boolean equals(Object obj) {
              if (obj == null) {
                  return false;
              }
              if (this.getClass() != obj.getClass()) {
                  return false;
              }
              Pair p = (Pair) obj;
              return this.x == p.x && this.y == p.y;
          }
  
          public Pair clone() {
              return new Pair(x, y);
          }
  
          public String toString() {
              return this.x + " " + this.y;
          }
  
          public void subtract(Pair p) {
              x -= p.x;
              y -= p.y;
          }
  
          public void add(Pair p) {
              x += p.x;
              y += p.y;
          }
      }
  }