Polycarp plays a well-known computer game (we won't mention its name). In this game, he can craft tools of two types — shovels and swords. To craft a shovel, Polycarp spends two sticks and one diamond; to craft a sword, Polycarp spends two diamonds and one stick.

Each tool can be sold for exactly one emerald. How many emeralds can Polycarp earn, if he has a sticks and b diamonds?

Input

The first line contains one integer t (1 ≤ t ≤ 1000) — the number of test cases.

The only line of each test case contains two integers a and b (0 ≤ a, b ≤ 10^9) — the number of sticks and the number of diamonds, respectively.

Output

For each test case print one integer — the maximum number of emeralds Polycarp can earn.

Example

Input


4
4 4
1000000000 0
7 15
8 7


Output


2
0
7
5

Note

In the first test case Polycarp can earn two emeralds as follows: craft one sword and one shovel.

In the second test case Polycarp does not have any diamonds, so he cannot craft anything.
#include <bits/stdc++.h>
using namespace std;
template <typename T>
T gcds(T x) {
  return x;
}
template <typename T, typename... S>
T gcds(T x, S... y) {
  return gcd(x, gcds(y...));
}
template <typename T>
T lcms(T x) {
  return x;
}
template <typename T, typename... S>
T lcms(T x, S... y) {
  return lcm(x, lcms(y...));
}
template <typename T>
T maxs(T x) {
  return x;
}
template <typename T, typename... S>
T maxs(T x, S... y) {
  return max(x, maxs(y...));
}
template <typename T>
T mins(T x) {
  return x;
}
template <typename T, typename... S>
T mins(T x, S... y) {
  return min(x, mins(y...));
}
void read() {}
template <typename T, typename... S>
void read(T& x, S&... y) {
  long long c = 0, n = x = 0;
  for (; !isdigit(c); c = getchar())
    if (c == '-') n = 1;
  for (; isdigit(c); c = getchar()) x = c - 48 + x * 10;
  if (n) x = -x;
  read(y...);
}
void write() { putchar('\n'); }
template <typename T, typename... S>
void write(T x, S... y) {
  static char s[64];
  long long t = 62;
  s[62] = 32;
  s[63] = 0;
  if (x < 0) {
    x = -x;
    putchar('-');
  }
  do s[--t] = x % 10 + 48;
  while (x /= 10);
  fputs(s + t, stdout);
  write(y...);
}
template <typename T>
signed compare(T x, T y) {
  return y - x > 1e-9 ? -1 : x - y > 1e-9 ? 1 : 0;
}
signed count_one(signed x) {
  x = (x & 0x55555555) + (x >> 1 & 0x55555555);
  x = (x & 0x33333333) + (x >> 2 & 0x33333333);
  x = (x & 0x0f0f0f0f) + (x >> 4 & 0x0f0f0f0f);
  x = (x & 0x00ff00ff) + (x >> 8 & 0x00ff00ff);
  x = (x & 0x0000ffff) + (x >> 16 & 0x0000ffff);
  return x;
}
int a, b, t;
signed main() {
  for (read(t); t--;) {
    read(a, b);
    if (b < a) {
      swap(a, b);
    }
    if (a << 1 <= b) {
      write(a);
    } else {
      write((a + b) / 3);
    }
  }
}
