#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  long long int t;
  cin >> t;
  while (t--) {
    long long int a, b;
    cin >> a >> b;
    if (a < b) {
      long long int z = a;
      a = b;
      b = z;
    }
    if (a == 0 || b == 0)
      cout << 0 << endl;
    else {
      if (a >= 2 * b)
        cout << b << endl;
      else {
        long long int z = a - b;
        b = b - z;
        if (b > 0) {
          if (b % 3 == 1)
            z += (b / 3) * 2;
          else if (b % 3 == 2)
            z += (b / 3) * 2 + 1;
          else
            z += (b / 3) * 2;
        }
        cout << z << endl;
      }
    }
  }
}
