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.*;
  import java.io.*;
  
  public class d {
  
      public static void main(String[] args){
  
          FastScanner sc = new FastScanner();
          int t = sc.nextInt();
          while(t-- > 0){
  
              long x = sc.nextLong();
              long y = sc.nextLong();
  
              if(y == x){
                  System.out.println(y);
                  continue;
              }
  
              if(y < x){
                  System.out.println(x+y);
                  continue;
              }
  
              long lo = x;
              long hi = y;
  
              while(lo <= hi){
  
                  long mid = (lo + hi)/2;
                  if(y%mid == mid%x){
                      System.out.println(mid);
                      break;
                  }
  
                  if(y%mid > mid%x){
                      lo = mid+1;
                  }
                  else{
                      hi = mid-1;
                  }
  
              }
  
          }
  
      }
  
  }
  
  class FastScanner {
  
      //I don't understand how this works lmao
      private int BS = 1 << 16;
      private char NC = (char) 0;
      private byte[] buf = new byte[BS];
      private int bId = 0, size = 0;
      private char c = NC;
      private double cnt = 1;
      private BufferedInputStream in;
  
      public FastScanner() {
          in = new BufferedInputStream(System.in, BS);
      }
  
      public FastScanner(String s) {
          try {
              in = new BufferedInputStream(new FileInputStream(new File(s)), BS);
          } catch (Exception e) {
              in = new BufferedInputStream(System.in, BS);
          }
      }
  
      private char getChar() {
          while (bId == size) {
              try {
                  size = in.read(buf);
              } catch (Exception e) {
                  return NC;
              }
              if (size == -1) return NC;
              bId = 0;
          }
          return (char) buf[bId++];
      }
  
      public int nextInt() {
          return (int) nextLong();
      }
  
      public int[] nextInts(int N) {
          int[] res = new int[N];
          for (int i = 0; i < N; i++) {
              res[i] = (int) nextLong();
          }
          return res;
      }
  
      public long[] nextLongs(int N) {
          long[] res = new long[N];
          for (int i = 0; i < N; i++) {
              res[i] = nextLong();
          }
          return res;
      }
  
      public long nextLong() {
          cnt = 1;
          boolean neg = false;
          if (c == NC) c = getChar();
          for (; (c < '0' || c > '9'); c = getChar()) {
              if (c == '-') neg = true;
          }
          long res = 0;
          for (; c >= '0' && c <= '9'; c = getChar()) {
              res = (res << 3) + (res << 1) + c - '0';
              cnt *= 10;
          }
          return neg ? -res : res;
      }
  
      public double nextDouble() {
          double cur = nextLong();
          return c != '.' ? cur : cur + nextLong() / cnt;
      }
  
      public double[] nextDoubles(int N) {
          double[] res = new double[N];
          for (int i = 0; i < N; i++) {
              res[i] = nextDouble();
          }
          return res;
      }
  
      public String next() {
          StringBuilder res = new StringBuilder();
          while (c <= 32) c = getChar();
          while (c > 32) {
              res.append(c);
              c = getChar();
          }
          return res.toString();
      }
  
      public String nextLine() {
          StringBuilder res = new StringBuilder();
          while (c <= 32) c = getChar();
          while (c != '\n') {
              res.append(c);
              c = getChar();
          }
          return res.toString();
      }
  
      public boolean hasNext() {
          if (c > 32) return true;
          while (true) {
              c = getChar();
              if (c == NC) return false;
              else if (c > 32) return true;
          }
      }
  }