#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int t;
  cin >> t;
  while (t--) {
    int a, b;
    cin >> a >> b;
    if (a < b) swap(a, b);
    int ans = min(a / 2, b), inc = 0;
    b -= ans;
    if ((a & 1) && b > 1) a = 0, b -= 2, inc++;
    ans += b / 3 + inc;
    cout << ans << endl;
  }
  return 0;
}
