#include

#include

#include<math.h>

using namespace std;

int main()

{

unsigned long long int i,j,pos1,pos2,num1,num2,cases;

cin>>cases;

while(cases–)

{

cin>>i>>j;

pos1 = log(i)/log(2) + 1;

pos2 = log(j)/log(2) + 1;

num1 = pos1;

num2 = pos2;

if(pos1>pos2)

{

while(pos1!=pos2)

{

i = i/2;

pos1–;

}

}

else if(pos2>pos1)

{

while(pos2!=pos1)

{

j = j/2;

pos2–;

}

}

if(i==j)

cout<<(num1+num2-2*pos1)<<endl;
else
{
while(i!=j)
{
i=i/2;
j=j/2;
pos1–;
}
cout<<(num1+num2-2*pos1)<<endl;

}

}

return 0;

}