#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
ios::sync_with_stdio(false);
cin.tie(0);
int t;
ll x, y;
cin >> t;
while(t--){
cin >> x >> y;
if(x > y) swap(x, y);
ll ans = 0;
while((ll)(log2(x)) != (ll)(log2(y))){
y >>= 1;
ans += 1;
}
while(x != y){
x >>= 1;
y >>= 1;
ans += 2;
}
cout << ans << '\n';
}
return 0;
}