#include using namespace std; int main(){ int q; cin >> q; for(int a0 = 0; a0 < q; a0++){ int len; int c; cin >> len >> c; if (len == 1) { if (c == 0) { cout << "1" << endl; } else { cout << "-1" << endl; } continue; } if (c > len*(len-1)/2) { cout << "-1" << endl; continue; } // safe zone } return 0; }