#include #include #include using namespace atcoder; using mint = modint998244353; using namespace std; #define rep(i,n) for (int i = 0; i < (n); ++i) #define Inf 1000000001 int main(){ int n,q; cin>>n>>q; rep(_,q){ long long s,t; cin>>s>>t; int ans = 0; while(s!=t){ int ind = -1; rep(i,n){ if((s>>i)&1){ ind = i; break; } } if(ind==-1 || (s+(1LL<t){ ans += __builtin_popcountll(s^t); break; } ans++; s += 1LL<