#include <bits/stdc++.h>
using namespace std;
void fastio() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
}
int main() {
  fastio();
  int i, j, k, t, l, r, x;
  long long a, b, s;
  cin >> t;
  while (t--) {
    cin >> a >> b;
    s = min(min(a, b), (a + b) / 3);
    cout << s << endl;
  }
  return 0;
}
