#include <bits/stdc++.h>
using namespace std;
int main() {
  long long tc, ans;
  cin >> tc;
  while (tc--) {
    int ans = 0;
    int a, b;
    cin >> a >> b;
    if (a > b) {
      a ^= b;
      b ^= a;
      a ^= b;
    }
    int dif = b - a;
    if (dif >= a) {
      ans = a;
    } else if (dif < a) {
      b -= 2 * dif;
      a -= dif;
      ans += dif;
      if (b == a) {
        ans += (b + a) / 3;
      }
    }
    cout << ans << "\n";
  }
  return 0;
}
