#include <bits/stdc++.h>
int T;
int n, m;
int main() {
  scanf("%d", &T);
  while (T--) {
    scanf("%d%d", &n, &m);
    int t = std::min(n, m);
    n = std::max(n, m);
    m = t;
    int s = 0;
    t = std::min(m, n - m);
    s += std::min(m, n - m);
    n -= 2 * t, m -= t;
    printf("%d\n",
           s + (std::min(n, m) / 3 * 2) +
               bool(((n % 3) >= 1 && (m % 3) >= 1 && (n % 3) + (m % 3) >= 3)));
  }
  return 0;
}
