#include <bits/stdc++.h>
using namespace std;
int32_t main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long n = 0, a, b, res = 0, c = 1, d = 1, temp = 0;
  cin >> n;
  while (n--) {
    cin >> a >> b;
    if (a == 0 || b == 0) {
      cout << 0 << "\n";
      continue;
    }
    if (max(a, b) / min(a, b) >= 2) {
      cout << min(a, b) << "\n";
      continue;
    } else {
      cout << (a + b) / 3 << "\n";
    }
  }
  return 0;
}
