#include using namespace std; using ll=long long; ll f(ll N){ if(__builtin_popcount(N+1)==1){ return N-(N/2); } else{ return N-((N+1)&(-N-1))+1; } } void solve(){ ll N,M; cin>>N>>M; ll x=0; ll an=0; for(int i=0;i>B; an+=f(B-x-1); x=B; } an+=f(N-x); cout<>T; while(T--)solve(); }