#include<bits/stdc++.h>
#define fre(x) freopen(#x".in","r",stdin); freopen(#x".out","w",stdout);
#define Fre(x,y) freopen(#x".in","r",stdin); freopen(#y".out","w",stdout);
#define IsDigit(c) ('0'<=(c) && (c)<='9')
#define MAX 5 +
#define Enter putchar('\n');
#define Space putchar(' ');
#define LL long long
#define INF 1<<30
#define p
using namespace std;
inline int read()
{
int x=0; bool f=true;
char c=getchar();
for (;!IsDigit(c);c=getchar()) if (c=='-') f=false;
for (;IsDigit(c);c=getchar()) x=(x<<3)+(x<<1)+(c^'0');
return f ? x : -x;
}
inline void write(int x)
{
if (x<0)
{
putchar('-');
x=-x;
}
if (x>9) write(x/10);
putchar(x%10+'0');
}
int n,Ans;
signed main()
{
// fre();
n=read();
for (register int x,y,i=1;i<=n;i++)
{
x=read(); y=read();
Ans=0;
while (x!=y)
{
Ans++;
if (x<y) swap(x,y);
x/=2;
}
write(Ans); Enter;
}
return 0;
}