#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  cin >> t;
  int* a = new int[t];
  int* b = new int[t];
  for (int i = 0; i < t; ++i) {
    cin >> a[i] >> b[i];
  }
  int temp, maxEmeralds;
  int n = 0;
  for (int i = 0; i < t; ++i) {
    n = 0;
    maxEmeralds = 0;
    n = floor((a[i] - b[i] / 2.0) * 2.0 / 3.0);
    n = min(n, a[i] / 2);
    n = min(n, b[i]);
    if (n >= 0) {
      maxEmeralds = floor(b[i] / 2.0 + n / 2.0);
    }
    n = ceil((a[i] - b[i] / 2.0) * 2.0 / 3.0);
    n = max(n, 0);
    if (n <= b[i] && n <= a[i] / 2) {
      temp = floor(a[i] - n);
      if (temp > maxEmeralds) maxEmeralds = temp;
    }
    cout << maxEmeralds << endl;
  }
  delete[] a;
  delete[] b;
  return 0;
}
