#include <bits/stdc++.h>
using namespace std;
int main() {
  int test;
  cin >> test;
  while (test--) {
    long long int n, m;
    cin >> n >> m;
    long long int t = min(n, m);
    n = max(n, m);
    m = t;
    if (n >= m * 2)
      cout << m << "\n";
    else {
      long long int ans = n - m;
      n -= (n - m) * 2;
      ans += n / 3 * 2;
      n = n % 3;
      if (n == 2) ans++;
      cout << ans << "\n";
    }
  }
}
