#include <bits/stdc++.h>
using namespace std;
int main() {
  int t, a, b, x, y;
  int i, ans, temp;
  cin >> t;
  for (i = 0; i < t; i++) {
    cin >> a >> b;
    if (a == 0 || b == 0) {
      cout << 0 << endl;
      continue;
    }
    x = ((2 * a) - b) / 3;
    y = ((2 * b) - a) / 3;
    if (x < 0 || y < 0) {
      (a < b) ? cout << a << endl : cout << b << endl;
      continue;
    }
    cout << ((a + b) / 3) << endl;
  }
}
