#include <bits/stdc++.h>
using namespace std;
int solve(int x, int y){
while(x > y){
y += y;
}
return y;
}
int main()
{
int n;
cin >> n;
for(int i=0; i<n; i++){
int x, y;
cin >> x >> y;
cout << solve(x, y) << endl;
}
return 0;
}