#include <bits/stdc++.h>
using namespace std;
int t;
long long a, b, ans, k, l;
int main() {
  cin >> t;
  while (t--) {
    cin >> a >> b;
    ans = a;
    a = max(a, b);
    b = min(ans, b);
    k = ((2 * a) - b) / 3;
    l = (b - k) / 2;
    cout << min(k + l, b) << endl;
  }
}
