#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  scanf("%d", &t);
  while (t--) {
    long long int a, b;
    scanf("%lld %lld", &a, &b);
    long long int ans = 0, c = min(a, b), d = max(a, b);
    a = c;
    b = d;
    if (a == 0 || b == 0) {
      printf("%d\n", 0);
      ;
    } else if (a * 2 <= b) {
      printf("%lld\n", a);
      ;
    } else {
      ans = (a / 3) + (b / 3);
      a = a % 3;
      b = b % 3;
      if (a + b >= 3) {
        ans++;
      }
      printf("%lld\n", ans);
      ;
    }
  }
  return 0;
}
