#include <bits/stdc++.h>
using namespace std;
int mv1[4] = {0, 1, 0, -1};
int mv2[4] = {1, 0, -1, 0};
int a, b, q;
int main(void) {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cin >> q;
  while (q--) {
    cin >> a >> b;
    int ans = abs(a - b);
    int maxv = max(a, b) - ans * 2;
    int minv = min(a, b) - ans;
    if (0 >= minv)
      cout << min(a, b) << "\n";
    else {
      ans += ((maxv / 3) * 2);
      maxv %= 3;
      ans += maxv / 2;
      cout << ans << "\n";
    }
  }
}
