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