#include using namespace std; #define ll long long #define rep(i, n) for (int i = 0; i < (int)(n); i++) template bool chmin(T& a, T b){if(a > b){a = b; return true;} return false;} template bool chmax(T& a, T b){if(a < b){a = b; return true;} return false;} const long long mod=998244353; const long long mod2=469762049; void solve(){ ll N,M;cin>>N>>M; ll l=0,r=2e14; while(l!=r){ ll m1=(l*2+r)/3,m2=(l+r*2)/3; if(m2*2>N) r=m1; ll cnt1=min((N-2*m1)/4,(M+4*m1)/2); ll cnt2=min((N-2*m2)/4,(M+4*m2)/2); if(cnt1sync_with_stdio(0); cin.tie(0); int T;cin>>T; while(T--) solve(); }