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.
1
1000000000 1000000000

1000000000 

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
template <class T>
using vt = vector<T>;
template <class T>
using vvt = vt<vt<T>>;
template <class T>
using pr = pair<T, T>;
template <typename T>
istream& operator>>(istream& is, vt<T>& v) {
  const size_t n = v.size();
  for (size_t i = 0; i < n; ++i) is >> v[i];
  return is;
}
template <typename T>
ostream& operator<<(ostream& os, const vt<T>& v) {
  const size_t n = v.size();
  for (size_t i = 0; i < n; ++i) {
    if (i != 0) os << ' ';
    os << v[i];
  }
  return os;
}
template <typename T>
istream& operator>>(istream& is, vvt<T>& vv) {
  const size_t n = vv.size();
  const size_t m = vv[0].size();
  for (size_t i = 0; i < n; ++i)
    for (size_t j = 0; j < m; ++j) is >> vv[i][j];
  return is;
}
template <typename T>
ostream& operator<<(ostream& os, const vvt<T>& vv) {
  const size_t n = vv.size();
  const size_t m = vv[0].size();
  for (size_t i = 0; i < n; ++i) {
    if (i != 0) os << '\n';
    for (size_t j = 0; j < m; ++j) {
      if (j != 0) os << ' ';
      os << vv[i][j];
    }
  }
  return os;
}
template <typename T, typename U>
istream& operator>>(istream& is, pair<T, U>& p) {
  is >> p.first >> p.second;
  return is;
}
template <typename T, typename U>
ostream& operator<<(ostream& os, const pair<T, U>& p) {
  os << p.first << ' ' << p.second;
  return os;
}
template <class A, class B>
string to_string(pair<A, B> p);
template <class A, class B, class C>
string to_string(tuple<A, B, C> p);
template <class A, class B, class C, class D>
string to_string(tuple<A, B, C, D> p);
string to_string(const string& s) { return '"' + s + '"'; }
string to_string(const char* s) { return to_string((string)s); }
string to_string(const char& c) { return (string) "" + c; }
string to_string(bool b) { return (b ? "true" : "false"); }
string to_string(vector<bool> v) {
  bool first = true;
  string res = "{";
  for (int i = 0; i < static_cast<int>(v.size()); i++) {
    if (!first) res += ", ";
    first = false;
    res += to_string(v[i]);
  }
  res += "}";
  return res;
}
template <size_t N>
string to_string(bitset<N> v) {
  string res = "";
  for (size_t i = 0; i < N; i++) res += static_cast<char>('0' + v[i]);
  return res;
}
template <class A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto& x : v) {
    if (!first) res += ", ";
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}
template <class A, class B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
template <class A, class B, class C>
string to_string(tuple<A, B, C> p) {
  return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " +
         to_string(get<2>(p)) + ")";
}
template <class A, class B, class C, class D>
string to_string(tuple<A, B, C, D> p) {
  return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " +
         to_string(get<2>(p)) + ", " + to_string(get<3>(p)) + ")";
}
void debug_out() { cerr << endl; }
template <class Head, class... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
template <class T, class U>
bool chmax(T& a, U b) {
  if (a < b) {
    a = b;
    return true;
  } else
    return false;
}
template <class T, class U>
bool chmin(T& a, U b) {
  if (b < a) {
    a = b;
    return true;
  } else
    return false;
}
int32_t main() {
  std::ios::sync_with_stdio(false);
  std::cin.tie(nullptr);
  int T;
  cin >> T;
  while (T--) {
    ll x, y;
    cin >> x >> y;
    ll n;
    if (x <= y) {
      ll dist = (y - x);
      x += (dist / x) * x;
      assert(x <= y);
      n = (x + y) / 2;
    } else {
      n = x * y + y;
    }
    assert(n % x == y % n);
    cout << n << '\n';
  }
  return 0;
}
