#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  cin >> t;
  while (t--) {
    int p, q;
    cin >> p >> q;
    if (p >= 2 && q >= 2) {
      if (p == q) {
        cout << ((p + q) / 3) << endl;
      } else if (p > q) {
        if (p >= 2 * q)
          cout << q << endl;
        else
          cout << ((p + q) / 3) << endl;
      } else {
        if (q >= 2 * p)
          cout << p << endl;
        else
          cout << ((p + q) / 3) << endl;
      }
    } else if ((p >= 2 && q == 1) || (p == 1 && q >= 2))
      cout << 1 << endl;
    else
      cout << 0 << endl;
  }
  return 0;
}
