#include <bits/stdc++.h>
using namespace std;
void solve() {
  int a, b, c;
  cin >> a >> b;
  int ans = 0;
  if (b > a) swap(a, b);
  if (a - b) {
    c = a - b;
    ans = min(c, b);
    b -= ans;
    a = b;
  }
  ans += (a / 3) * 2 + (a % 3) / 2;
  cout << ans << "\n";
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int t;
  cin >> t;
  while (t--) {
    solve();
  }
  return 0;
}
