#include <bits/stdc++.h>
using namespace std;
void solve() {
  long long a, b;
  cin >> a >> b;
  if (a == 0 || b == 0) {
    cout << 0 << endl;
    return;
  }
  cout << min((a + b) / 3, min(a, b)) << endl;
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int tc = 1;
  cin >> tc;
  while (tc--) solve();
}
