#include using namespace std; int main(){ ios_base::sync_with_stdio(false); cin.tie(nullptr); int test; cin >> test; while(test--){ long long N,X; cin >> N >> X; long long minx = (N+1)*N/2; if(minx > X){cout << -1 << endl; continue;} long long more = X-minx,add = more/N; more %= N; for(int i=0; i