#include <bits/stdc++.h>
using namespace std;
int main()
{
int n;
cin >> n;
while (n -- )
{
int x, y;
cin >> x >> y;
int k = ceil((double)y / (x + 1));
// cout << k << endl;
if (y == 0) cout << 0 << endl;
else
{
if ((k - 1) * (x + 1) + 1 >= y)
cout << 2 * k - 1 << endl;
else cout << 2 * k << endl;
}
}
return 0;
}