#include using namespace std; using ll = long long; int main(){ cin.tie(nullptr); ios::sync_with_stdio(false); ll t; cin>>t; while(t--){ ll x,y; cin>>x>>y; ll ans = 0; ll ni = y; while(ni<30){ if(~x>>ni&1) break; ni++; } ni--; while(ni>=0){ ans += 1ll<