不知道哪错了qwq……
#include<bits/stdc++.h>
using namespace std;
int T,x,y,ans;
int minn(int x,int y,int z){
return min(x,min(y,z));
}
void dfs(int pos,int tar,int step){
if(pos==tar){
ans=min(ans,step);
return;
}
dfs(pos-1,tar,step+1);
dfs(pos+1,tar,step+1);
dfs(pos*2,tar,step+1);
}
int main(){
cin>>T;
while(T--){
cin>>x>>y;
if(x>=y){
cout<<x-y<<endl;
continue;
}
ans=1e9;
dfs(x,y,0);
cout<<ans<<endl;
}
}