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.round752div2;
  
  import java.io.*;
  import java.util.*;
  
  import static java.lang.Math.*;
  
  //Think through the entire logic before jump into coding!
  //If you are out of ideas, take a guess! It is better than doing nothing!
  //Read both C and D, it is possible that D is easier than C for you!
  
  //Be aware of integer overflow!
  //If you find an answer and want to return immediately, don't forget to flush before return!
  
  public class D {
      static InputReader in;
      static PrintWriter out;
  
      public static void main(String[] args) {
          //initReaderPrinter(true);
          initReaderPrinter(false);
          solve(in.nextInt());
          //solve(1);        
      }
  
      static void solve(int testCnt) {
          for (int testNumber = 0; testNumber < testCnt; testNumber++) {
              long x = in.nextLong(), y = in.nextLong();
              long n = x > y ? x + y : (y - y % x) + y % x / 2;
              out.println(n);
          }
          out.close();
      }
  
      static void initReaderPrinter(boolean test) {
          if (test) {
              try {
                  in = new InputReader(new FileInputStream("src/input.in"));
                  out = new PrintWriter(new FileOutputStream("src/output.out"));
              } catch (IOException e) {
                  e.printStackTrace();
              }
          } else {
              in = new InputReader(System.in);
              out = new PrintWriter(System.out);
          }
      }
  
      static class InputReader {
          BufferedReader br;
          StringTokenizer st;
  
          InputReader(InputStream stream) {
              try {
                  br = new BufferedReader(new InputStreamReader(stream), 32768);
              } catch (Exception e) {
                  e.printStackTrace();
              }
          }
  
          String next() {
              while (st == null || !st.hasMoreTokens()) {
                  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;
          }
  
          Integer[] nextIntArray(int n) {
              Integer[] a = new Integer[n];
              for (int i = 0; i < n; i++) a[i] = nextInt();
              return a;
          }
  
          int[] nextIntArrayPrimitive(int n) {
              int[] a = new int[n];
              for (int i = 0; i < n; i++) a[i] = nextInt();
              return a;
          }
  
          int[] nextIntArrayPrimitiveOneIndexed(int n) {
              int[] a = new int[n + 1];
              for (int i = 1; i <= n; i++) a[i] = nextInt();
              return a;
          }
  
          Long[] nextLongArray(int n) {
              Long[] a = new Long[n];
              for (int i = 0; i < n; i++) a[i] = nextLong();
              return a;
          }
  
          long[] nextLongArrayPrimitive(int n) {
              long[] a = new long[n];
              for (int i = 0; i < n; i++) a[i] = nextLong();
              return a;
          }
  
          long[] nextLongArrayPrimitiveOneIndexed(int n) {
              long[] a = new long[n + 1];
              for (int i = 1; i <= n; i++) a[i] = nextLong();
              return a;
          }
  
          String[] nextStringArray(int n) {
              String[] g = new String[n];
              for (int i = 0; i < n; i++) g[i] = next();
              return g;
          }
      }
  }