#include <bits/stdc++.h>
using namespace std;
int main() {
  long t;
  cin >> t;
  while (t--) {
    long a, b, answer;
    cin >> a >> b;
    if (a == 0 || b == 0) {
      answer = 0;
    } else if (a * 2 <= b) {
      answer = a;
    } else if (2 * b <= a) {
      answer = b;
    } else {
      answer = ceil((a + b) / 3);
    }
    cout << answer << "\n";
  }
  return 0;
}
