#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  cin >> t;
  while (t--) {
    long long int a, b;
    cin >> a >> b;
    if (a == 0 || b == 0)
      cout << 0 << endl;
    else {
      if (a == b)
        cout << (a + b) / 3 << endl;
      else {
        if (a < b) {
          if (2 * a <= b)
            cout << a << endl;
          else {
            cout << a / 3 + b / 3 + (a % 3 + b % 3) / 3 << endl;
          }
        } else {
          if (2 * b <= a)
            cout << b << endl;
          else {
            cout << a / 3 + b / 3 + (a % 3 + b % 3) / 3 << endl;
          }
        }
      }
    }
  }
  return 0;
}
