#include <bits/stdc++.h>
using namespace std;
const long long int inf = 0x3f3f3f3f3f3f3f3fll;
const int N = 4000000, mod = 1000000007;
int main() {
  ios::sync_with_stdio(0);
  std::cin.tie(0);
  std::cout.tie(0);
  int test;
  cin >> test;
  for (int tt = 1; tt <= test; tt++) {
    int a, b;
    cin >> a >> b;
    if (b > a) swap(a, b);
    int ans = min((a - b), b);
    a = b - ans;
    ans += (a / 3) * 2;
    int temp2 = (a / 3) * 3;
    a = a - temp2;
    ans = ans + (a >= 2);
    cout << ans << "\n";
  }
  return 0;
}
