#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1e9 + 7;
long long T, a, b;
void solve() {
  cin >> a >> b;
  if (b > a) swap(a, b);
  a = min(a, b * 2);
  long long ans = a - b;
  a -= (ans * 2);
  b -= ans;
  ans += (a + b) / 3;
  cout << ans << "\n";
}
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie();
  cin >> T;
  while (T--) {
    solve();
  }
  return 0;
}
