#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 ans = min(a, min(b, (a + b) / 3));
    cout << ans << endl;
    t--;
  }
  return 0;
}
