#include using namespace std; int main(){ ios_base::sync_with_stdio(false); cin.tie(nullptr); int T; cin >> T; while(T--){ int L,R; cin >> L >> R; if(R == 0){cout << "0\n"; continue;} for(int d=30; d--;) if(R&(1<