#include <bits/stdc++.h>
using namespace std;
int main() {
  std::ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
  int T;
  cin >> T;
  while (T--) {
    int n, m;
    cin >> n >> m;
    int ans = 0;
    if (n < m) swap(n, m);
    if (n / 2 >= m)
      ans = m;
    else {
      ans = (n + m) / 3;
    }
    cout << ans << endl;
  }
  return 0;
}
