#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);
    if (2 * b <= a)
      cout << b << endl;
    else if (a == b) {
      int mod = a % 3;
      if (mod == 0) mod = 3;
      if (mod == 1) {
        cout << (a / 3) * 2 << endl;
      }
      if (mod == 2) {
        cout << (a / 3) * 2 + 1 << endl;
      }
      if (mod == 3) {
        cout << (a / 3) * 2 << endl;
      }
    } else {
      int p = a - b;
      a = a - 2 * p;
      b = b - p;
      if (a != b) {
        cout << b + p << endl;
      } else {
        int mod = a % 3;
        if (mod == 0) mod = 3;
        if (mod == 1) {
          cout << (a / 3) * 2 + p << endl;
        }
        if (mod == 2) {
          cout << (a / 3) * 2 + 1 + p << endl;
        }
        if (mod == 3) {
          cout << (a / 3) * 2 + p << endl;
        }
      }
    }
  }
  return 0;
}
