#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int t, n, m, i, ans;
  cin >> t;
  while (t--) {
    cin >> n >> m;
    ans = min(min(n, m), (n + m) / 3);
    cout << ans << "\n";
  }
}
