#include using namespace std; #include using namespace atcoder; #define ll long long #define rep(i, n) for (ll i = 0; i < (ll)(n); i++) //using mint = modint998244353; const int dx[4]={0,1,0,-1}; const int dy[4]={1,0,-1,0}; ll f(ll a,ll b){ ll c=1; vectorans; if(b%a==0)return 0; while(b-a*c>=c-1&&b-a*c>0){ c++; ll d=(b-a*c)%(c-1); ll e=(b-a*c)/(c-1); if(d==0&&e>0)ans.push_back (e); } if(!ans.empty())return ans[ans.size()-1]; return -1; } int main() { int t; cin>>t; while(t--){ ll a,b; cin>>a>>b; cout<