#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long t;
  cin >> t;
  while (t--) {
    int a, b;
    cin >> a >> b;
    int x = min(a, b);
    int y = max(a, b);
    if (2 * x <= y)
      cout << x << endl;
    else {
      int ans = 0;
      int diff = y - x;
      ans += diff;
      x -= diff;
      y -= 2 * diff;
      ans += (x / 3) * 2;
      if (x % 3 == 2) ans++;
      cout << ans << endl;
    }
  }
  return 0;
}
