// not my code
#include <bits/stdc++.h>
using namespace std;
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
using ll = long long;
ll get_ans(ll n, ll k) {
ll i, t, l, r, mid1, mid2, ans1, ans2, ans;
l = 0; r = (k+n-1)/n;
t = 100; while (l < r) {
mid1 = l + (r-l)/3;
mid2 = r - (r-l)/3;
ans1 = mid1 * (k - mid1*n);
ans2 = mid2 * (k - mid2*n);
if (ans1 > ans2) {
r = mid2;
} else {
l = mid1 + 1;
}
}
ans = 0;
for (i = l; i <= r; ++i) {
ans = max(ans, i * (k - i*n));
}
return ans;
}
int main() {
FAST;
int tc = 1, ti;
cin >> tc;
for (ti = 1; ti <= tc; ++ti) {
ll n, k;
cin >> n >> k;
cout << get_ans(n, k) << "\n";
}
return 0;
}