#include <bits/stdc++.h>
using namespace std;
long long gcd(long long a, long long b) { return b == 0 ? a : gcd(b, a % b); }
long long lcm(long long a, long long b) { return (a / gcd(a, b)) * b; }
int main() {
  int t;
  scanf("%d", &t);
  while (t--) {
    int a, b;
    scanf("%d %d", &a, &b);
    if (a == 0 or b == 0)
      printf("0\n");
    else if (a < b and a * 2 <= b)
      printf("%d\n", a);
    else if (b < a and b * 2 <= a)
      printf("%d\n", b);
    else
      printf("%d\n", (a + b) / 3);
  }
}
