#include<bits/stdc++.h>
using namespace std;
long long int emerald(long long int sticks ,long long int diamonds)
{
if(sticks <= 0 || diamonds <= 0 ||(sticks == 1 && diamonds == 1) )
return 0;
else
return max(1+emerald(sticks - 1 , diamonds-2), 1+emerald(sticks-2,diamonds-1));
}
int main()
{
int t;
cin>>t;
while(t--)
{
long long int sticks , diamonds;
cin>>sticks>>diamonds;
cout<<emerald(sticks,diamonds)<<"\n";
}
}
-----------------------------------------------------------------------