#include <bits/stdc++.h>
using namespace std;
void yes() { cout << "YES" << endl; }
void no() { cout << "NO" << endl; }
bool compare(long long int a, long long int b) { return a >= b; }
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int test;
  cin >> test;
  while (test--) {
    long long int a, b;
    cin >> a >> b;
    long long int ans = 0, count = 0, cnt = 0;
    bool flag = 1;
    long long int x = min(a, b), y = max(a, b);
    if (x * 2 <= y)
      ans = x;
    else {
      ans = y - x;
      x = x - ans;
      y = y - ans * 2;
      count = x / 3;
      count *= 2;
      cnt = x % 3;
      long long int dif = y - x + cnt;
      if (cnt == 1 && dif > 1) {
        count++;
      } else if (cnt == 2) {
        if (dif > 3)
          count += 2;
        else if (dif > 1)
          count++;
      }
      ans += count;
    }
    cout << ans << endl;
  }
}
