#include <bits/stdc++.h>
using namespace std;
long long ans = 0;
int main(int argc, char const *argv[]) {
  int t;
  cin >> t;
  while (t--) {
    int a, b, ans = 0;
    cin >> a >> b;
    if (a > b) swap(a, b);
    if (b >= 2 * a)
      cout << a << endl;
    else {
      ans = b - a;
      a = 2 * a - b;
      ans += (a * 2) / 3;
      cout << ans << endl;
    }
  }
}
